修改了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,19 +5,29 @@ import "qrc:///AicsKnowledgeBase/qml/global"
Item {
anchors.fill: parent
signal search(string tag)
signal open(string file)
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 {
id: listView
anchors.fill: parent
spacing: 10
header: disableHeader ? null :fileListItemHeader
header: disableHeader ? null : fileListItemHeader
model: fileListModel
delegate: fileListItemDelegate
Component.onCompleted: {
if (autoRequest) {
update()
} else {
listView.model = dataModel
}
}
}
@ -114,6 +124,7 @@ Item {
}
fileListModel.append(modelItem)
}
console.log(fileListModel)
listView.currentIndex = -1
})
}
@ -140,7 +151,8 @@ Item {
size: isDir ? 0 : model.size
stars: isDir ? 0 : model.stars
// split string to array
tags: isDir ? [] : model.tags.split(",")
tags: isDir ? [] : model.tags.length === 0 ? [] : model.tags.split(
",")
onTagClicked: {
emit: search(tag)
console.log(tag)
@ -165,7 +177,7 @@ Item {
type: "FOLDER"
}
ListElement {
uid: "2"
uuid: "2"
title: "File 2"
isDir: false
brief: "This is a test file"
@ -176,7 +188,7 @@ Item {
stars: 10
}
ListElement {
uid: "3"
uuid: "3"
title: "File 3"
isDir: false
brief: "This is a test file"

View File

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

View File

@ -18,32 +18,34 @@ FluArea {
// Layout.topMargin: 20
// text: "Search"
// }
/*
*/
ColumnLayout{
ColumnLayout {
width: parent.width
RowLayout{
width:parent.width
FluDropDownButton{
id:select_model
RowLayout {
width: parent.width
FluDropDownButton {
id: select_model
Layout.alignment: Qt.AlignLeft
text:"标题"
items:[
FluMenuItem{
text:"标题"
text: "标题"
items: [
FluMenuItem {
text: "标题"
onClicked: {
select_model.text = text
}
},
FluMenuItem{
text:"内容"
FluMenuItem {
text: "内容"
onClicked: {
select_model.text = text
}
},
FluMenuItem{
text:"标签"
FluMenuItem {
text: "标签"
onClicked: {
select_model.text = text
}
@ -51,91 +53,118 @@ FluArea {
]
}
FluTextBox{
FluTextBox {
//placeholderText:""
Layout.fillWidth: true
}
FluIconButton{
FluIconButton {
Layout.alignment: Qt.AlignRight
iconSource:FluentIcons.Search
iconSource: FluentIcons.Search
}
}
//
RowLayout{
id:selectFormat
width:parent.width
FluText{
RowLayout {
id: selectFormat
width: parent.width
FluText {
Layout.alignment: Qt.AlignLeft
text:"类型: "
text: "类型: "
}
FluCheckBox{
id:selectAllFormat
text:"all"
Component.onCompleted:{
FluCheckBox {
id: selectAllFormat
text: "all"
Component.onCompleted: {
clicked()
}
onClicked:{
selectVideo.checked=true
selectDoc.checked=true
selectAudio.checked=true
onClicked: {
selectVideo.checked = true
selectDoc.checked = true
selectAudio.checked = true
}
}
FluCheckBox{
id:selectVideo
text:"Video"
onClicked:{
FluCheckBox {
id: selectVideo
text: "Video"
onClicked: {
selectFormat.setAllStatus()
}
}
FluCheckBox{
id:selectDoc
text:"Doc"
onClicked:{
FluCheckBox {
id: selectDoc
text: "Doc"
onClicked: {
selectFormat.setAllStatus()
}
}
FluCheckBox{
id:selectAudio
text:"Audio"
onClicked:{
FluCheckBox {
id: selectAudio
text: "Audio"
onClicked: {
selectFormat.setAllStatus()
}
}
function setAllStatus() {
selectAllFormat.checked = selectVideo.checked && selectDoc.checked && selectAudio.checked
selectAllFormat.checked = selectVideo.checked
&& selectDoc.checked && selectAudio.checked
}
}
RowLayout{
width:parent.width
RowLayout {
width: parent.width
height: 32
FluText{
FluText {
id: tag
Layout.alignment: Qt.AlignLeft
text:"标签: "
text: "标签: "
}
Tag{
Tag {
width: 290
}
}
FluArea{
FluArea {
backgroundColor: "#f9f9f9"
border.width: 0
width: parent.width
height: 500
FileList{
FileList {
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
}
}
}
}
}