AicsKnowledgeBase_client/AicsKnowledgeBase/qml/component/FileListItem.qml

179 lines
5.8 KiB
QML
Raw Normal View History

2023-06-24 18:02:21 +08:00
import QtQuick 2.15
import FluentUI
import QtQuick.Layouts
2023-07-06 21:50:19 +08:00
import "qrc:///AicsKnowledgeBase/qml/global"
2023-06-24 18:02:21 +08:00
2023-07-01 08:56:14 +08:00
FluArea {
2023-06-24 18:02:21 +08:00
id: fileItem
2023-06-30 19:45:04 +08:00
property string uuid
2023-07-06 21:50:19 +08:00
property var fuuid: null
2023-06-24 18:02:21 +08:00
property string title
property string brief
property string date
property string type
property string suffix
property bool isDir: false
property int size
property int pageView
property var tags: []
property var notes: []
property int stars
2023-06-28 14:47:52 +08:00
property var colorList: ["blue", "green", "orange", "red", "yellow", "purple", "pink", "brown", "teal", "cyan", "gray", "darkgray"]
signal tagClicked(string tag)
signal refresh
FluMenu {
id: menu
FluMenuItem {
text: "重命名"
onClicked: {
dialog.open()
}
InputDialog {
id: dialog
title: "重命名"
buttonFlags: FluContentDialog.PositiveButton | FluContentDialog.NegativeButton
negativeText: "取消"
positiveText: "确定"
message: fileItem.title
onPositiveClicked: text => {
var param = {
2023-07-07 00:24:17 +08:00
"parentId": fileItem.fuuid,
"name": text
}
2023-07-07 00:24:17 +08:00
console.log(JSON.stringify(param))
Request.put(
"/knowledge/" + fileItem.uuid,
JSON.stringify(param), () => {
refresh()
})
}
}
}
FluMenuItem {
text: "移动至"
onClicked: {
2023-07-06 21:50:19 +08:00
moveDialog.load()
moveDialog.open()
}
TreeViewDialog {
id: moveDialog
title: "选择目标文件夹"
buttonFlags: FluContentDialog.PositiveButton | FluContentDialog.NegativeButton
negativeText: "取消"
positiveText: "确定"
onPositiveClicked: uuid => {
var param = {
"parentId": uuid,
"name": fileItem.title
}
2023-07-07 00:24:17 +08:00
console.log(JSON.stringify(param))
2023-07-06 21:50:19 +08:00
Request.put(
"/knowledge/" + fileItem.uuid,
JSON.stringify(param), () => {
refresh()
})
}
}
}
FluMenuItem {
text: "删除"
onClicked: {
Request.delete("/knowledge/" + uuid)
refresh()
}
}
}
2023-07-01 08:56:14 +08:00
2023-07-07 01:57:39 +08:00
MouseArea {
anchors.fill: row
acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: {
fileItem.parent.doubleClicked()
}
onClicked: {
if (mouse.button === Qt.RightButton) {
menu.popup()
}
}
}
2023-06-24 18:02:21 +08:00
ColumnLayout {
2023-07-07 01:57:39 +08:00
id: clickable
anchors.fill: row
2023-06-24 18:02:21 +08:00
2023-07-07 01:57:39 +08:00
RowLayout {
id: titleRow
Image {
id: icon
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
2023-07-07 03:10:40 +08:00
fillMode: Image.PreserveAspectFit
2023-06-24 18:02:21 +08:00
}
2023-07-07 01:57:39 +08:00
FluText {
id: title
font.bold: true
font.pointSize: 12
text: fileItem.title
textFormat: Text.RichText
2023-06-24 18:02:21 +08:00
}
2023-07-07 01:57:39 +08:00
}
2023-06-24 18:02:21 +08:00
FluText {
2023-06-28 14:47:52 +08:00
id: brief
visible: !fileItem.isDir
text: fileItem.brief
2023-07-05 22:31:14 +08:00
Layout.fillWidth: true
2023-07-07 03:26:13 +08:00
wrapMode: Text.WordWrap
2023-07-05 22:31:14 +08:00
elide: Text.ElideRight
2023-07-07 03:26:13 +08:00
maximumLineCount: 4
2023-07-06 22:23:15 +08:00
textFormat: Text.RichText
2023-07-07 03:26:13 +08:00
fontSizeMode: Text.Fit
2023-06-24 18:02:21 +08:00
}
2023-06-28 14:47:52 +08:00
RowLayout {
id: infoRow
visible: !fileItem.isDir
FluText {
id: date
2023-07-05 22:31:14 +08:00
color: "#5F5F5F"
2023-06-28 14:47:52 +08:00
text: fileItem.date
}
FluText {
id: size
// cast Byte size to right text size
2023-07-05 22:31:14 +08:00
color: "#5F5F5F"
2023-06-28 14:47:52 +08:00
text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed(
2) + "KB"
}
FluText {
id: pageView
2023-07-05 22:31:14 +08:00
color: "#5F5F5F"
2023-06-30 19:45:04 +08:00
text: fileItem.pageView + "浏览"
2023-06-28 14:47:52 +08:00
}
FluText {
id: stars
2023-07-05 22:31:14 +08:00
color: "#5F5F5F"
2023-06-28 14:47:52 +08:00
text: fileItem.stars + "收藏"
}
2023-06-24 18:02:21 +08:00
}
2023-06-28 14:47:52 +08:00
}
RowLayout {
visible: !fileItem.isDir
Repeater {
model: fileItem.tags
delegate: FluTextButton {
text: "#" + fileItem.tags[index]
normalColor: colorList[index % colorList.length]
font.pixelSize: 12
Layout.preferredWidth: 50
onClicked: {
emit: tagClicked(text)
}
}
2023-06-24 18:02:21 +08:00
}
}
}
}