アナログツリービュー
RowLayout {
anchors.fill:親
// anchors.top:header.bottom
間隔:50
長方形{
Layout.preferredWidth:150
Layout.preferredHeight:600
リストビュー{
ID:ListViewコントロール
anchors.fill:親
anchors.top:parent.top
anchors.topMargin:20
間隔:20
モデル:ListModelの{
ID:のListModel
{listelement
bgpId:2
bgpName: 'すべて'
レベル:0
サブノード:[]
}
}
デリゲート:list_delegate
Component.onCompleted:{
//カテゴリーを見ます
取得する(""、
関数(結果、JSON){
{(JSONでVAR 0)のための
IF(JSON [O] .parentId == 2){
{(JSONでのvar CID)のために
IF(JSON [CID] .parentId == JSON [O] .ID){
addModelData(JSON [O] .ID、JSON [O] .nameの、JSON [CID] .ID、JSON [CID] .nameの)
}
}
}
}
}
)
//すべてのバックグラウンドを取得
GETINFO(2)
}
}
}
長方形{
Layout.alignment:Qt.AlignTop
Layout.preferredWidth:parent.width-200
Layout.preferredHeight:parent.height
ScrollView {
anchors.fill:親
verticalScrollBarPolicy:Qt.ScrollBarAlwaysOff
フロー{
幅:parent.parent.width
rightPadding:30
間隔:30
リピータ{
モデル:contactModel
画像{
sourceSize.height:100
ソース:imgurl
テキスト{
幅:parent.width
anchors.top:parent.bottom
たHorizontalAlignment:Text.AlignHCenter
font.pointSize:10
テキスト:名前
}
}
}
}
}
}
}
ListModelの{
ID:contactModel
}
成分{
ID:list_delegate
カラム{
ID:objColumn
Component.onCompleted:{
用(VARのi = 1; iがobjColumn.children.length < - 1; ++ I){
objColumn.children偽= [i]は.visible
}
}
MouseArea {
幅:listView.width
高さ:objItem.implicitHeight
//有効:objColumn.children.length> 2
onClicked:{
console.log(bgpId)
//分類IDに応じて背景データを取得します
GETINFO(bgpId)
フラグ= falseでし
用(VARのi = 1; iはparent.children.length < - 1; ++ I){
フラグ= parent.children [I] .visible。
parent.children [i]は.visible =!parent.children [i]は.visible
}
(もし!フラグ){
iconAin.from = 0
iconAin.to = 90
iconAin.start()
}
他の{
iconAin.from = 90
iconAin.to = 0
iconAin.start()
}
}
行{
ID:objItem
間隔:10
leftPadding:20
画像{
ID:アイコン
幅:10
高さ:20
ソース: "../res/blockicons/Foward.svg"
anchors.verticalCenter:parent.verticalCenter
RotationAnimation {
ID:iconAin
ターゲット:アイコン
期間:100
}
}
ラベル{
テキスト:bgpName
カラー:「グレー」
anchors.verticalCenter:parent.verticalCenter
}
}
}
リピータ{
モデル:サブノード
デリゲート:長方形{
幅:parent.width
高さ:40
カラム{
アンカー{
LEFTMARGIN:20
トップ:parent.top
}
突破鼎:10
間隔:2
ラベル{
たHorizontalAlignment:Text.AlignHCenter
幅:100
テキスト:model.bgcName
MouseArea {
anchors.fill:親
onClicked:{
console.log(model.bgcId)
//同上背景データは、サブカテゴリーに基づいて取得します
GETINFO(model.bgcId)
}
}
}
}
}
}
}
}
//追加
関数addModelData(bgpId、bgpName、bgcId、bgcName){
VAR指数= findIndex(bgpId)
IF(インデックス=== -1){
listModel.append({ "bgpId":bgpId、 "bgpName":bgpName、 "レベル":0、
"サブノード":[{ "bgcId":bgcId、 "bgcName":bgcName、 "レベル":1、 "サブノード":[]}]})
}
他の{
listModel.get(インデックス).subNode.append({ "bgcId":bgcId、 "bgcName":bgcName、 "レベル":1、 "サブノード":[]})
}
}
//検索
関数findIndex(ID){
用(VARのI = 0; I <listModel.count; ++ I){
IF(listModel.get(I).bgpId === ID){
私を返します
}
}
-1を返します
}