修改了FileList的数据来源规则

main
karlis 2023-07-05 13:58:03 +08:00
parent a9fd98043b
commit 7be44d40b1
3 changed files with 130 additions and 87 deletions

View File

@ -5,10 +5,16 @@ import "qrc:///AicsKnowledgeBase/qml/global"
Item { Item {
anchors.fill: parent anchors.fill: parent
signal search(string tag) signal search(string tag)
signal open(string file) signal open(string file)
property bool disableHeader: false property bool disableHeader: false
property bool autoRequest: false
property string url: "http://127.0.0.1:4523/m1/2914957-0-5604d062/"
property ListModel dataModel: ListModel {}
function setListData(listmodel) {
listView.model = listmodel
}
ListView { ListView {
id: listView id: listView
anchors.fill: parent anchors.fill: parent
@ -17,7 +23,11 @@ Item {
model: fileListModel model: fileListModel
delegate: fileListItemDelegate delegate: fileListItemDelegate
Component.onCompleted: { Component.onCompleted: {
if (autoRequest) {
update() update()
} else {
listView.model = dataModel
}
} }
} }
@ -114,6 +124,7 @@ Item {
} }
fileListModel.append(modelItem) fileListModel.append(modelItem)
} }
console.log(fileListModel)
listView.currentIndex = -1 listView.currentIndex = -1
}) })
} }
@ -140,7 +151,8 @@ Item {
size: isDir ? 0 : model.size size: isDir ? 0 : model.size
stars: isDir ? 0 : model.stars stars: isDir ? 0 : model.stars
// split string to array // split string to array
tags: isDir ? [] : model.tags.split(",") tags: isDir ? [] : model.tags.length === 0 ? [] : model.tags.split(
",")
onTagClicked: { onTagClicked: {
emit: search(tag) emit: search(tag)
console.log(tag) console.log(tag)
@ -165,7 +177,7 @@ Item {
type: "FOLDER" type: "FOLDER"
} }
ListElement { ListElement {
uid: "2" uuid: "2"
title: "File 2" title: "File 2"
isDir: false isDir: false
brief: "This is a test file" brief: "This is a test file"
@ -176,7 +188,7 @@ Item {
stars: 10 stars: 10
} }
ListElement { ListElement {
uid: "3" uuid: "3"
title: "File 3" title: "File 3"
isDir: false isDir: false
brief: "This is a test file" brief: "This is a test file"

View File

@ -37,5 +37,7 @@ FluArea {
} }
} }
FileList {} FileList {
autoRequest: true
}
} }

View File

@ -18,6 +18,8 @@ FluArea {
// Layout.topMargin: 20 // Layout.topMargin: 20
// text: "Search" // text: "Search"
// } // }
/* /*
*/ */
@ -54,7 +56,6 @@ FluArea {
FluTextBox { FluTextBox {
//placeholderText:"" //placeholderText:""
Layout.fillWidth: true Layout.fillWidth: true
} }
FluIconButton { FluIconButton {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
@ -62,7 +63,6 @@ FluArea {
} }
} }
// //
RowLayout { RowLayout {
id: selectFormat id: selectFormat
@ -107,7 +107,8 @@ FluArea {
} }
function setAllStatus() { function setAllStatus() {
selectAllFormat.checked = selectVideo.checked && selectDoc.checked && selectAudio.checked selectAllFormat.checked = selectVideo.checked
&& selectDoc.checked && selectAudio.checked
} }
} }
@ -120,14 +121,11 @@ FluArea {
text: "标签: " text: "标签: "
} }
Tag { Tag {
width: 290 width: 290
} }
} }
FluArea { FluArea {
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
border.width: 0 border.width: 0
@ -136,6 +134,37 @@ FluArea {
FileList { FileList {
disableHeader: true disableHeader: true
dataModel: ListModel {
ListElement {
uuid: "0"
title: "File 1"
isDir: true
brief: "This is a test file"
type: "FOLDER"
}
ListElement {
uuid: "2"
title: "File 2"
isDir: false
brief: "This is a test file"
size: 500
type: "WORD"
date: "2020-09-09"
pageView: 100
stars: 10
}
ListElement {
uuid: "3"
title: "File 3"
isDir: false
brief: "This is a test file"
type: "PPT"
date: "2020-09-09"
pageView: 100
size: 10200000022
stars: 10
}
}
} }
} }
} }