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