AicsKnowledgeBase_client/AicsKnowledgeBase/qml/component/FileListItem.qml

98 lines
2.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-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-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)
2023-07-01 08:56:14 +08:00
2023-06-24 18:02:21 +08:00
ColumnLayout {
id: row
anchors.fill: parent
anchors.margins: 10
spacing: 10
2023-06-28 14:47:52 +08:00
ColumnLayout {
id: clickable
anchors.fill: parent
MouseArea {
anchors.fill: parent
onDoubleClicked: {
fileItem.parent.doubleClicked()
}
2023-06-24 18:02:21 +08:00
}
2023-06-28 14:47:52 +08:00
RowLayout {
id: titleRow
Image {
id: icon
2023-07-01 08:56:14 +08:00
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
2023-06-28 14:47:52 +08:00
Layout.preferredHeight: 18
Layout.preferredWidth: 18
}
FluText {
id: title
text: fileItem.title
}
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-06-24 18:02:21 +08:00
}
2023-06-28 14:47:52 +08:00
RowLayout {
id: infoRow
visible: !fileItem.isDir
FluText {
id: date
text: fileItem.date
}
FluText {
id: size
// cast Byte size to right text size
text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed(
2) + "KB"
}
FluText {
id: pageView
2023-06-30 19:45:04 +08:00
text: fileItem.pageView + "浏览"
2023-06-28 14:47:52 +08:00
}
FluText {
id: stars
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
}
}
}
}