解决了FileListItem的警告

main
wuyize 2023-07-07 01:57:39 +08:00
parent b6627ccd2c
commit e10fddb188
4 changed files with 80 additions and 114 deletions

View File

@ -164,47 +164,8 @@ Item {
} }
} }
} }
FluButton { UploadButton {
id: uploadIcon
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
let name = FileTransferManager.getFileName(
selectedFile)
const size = FileTransferManager.getFileSize(
selectedFile)
const md5 = FileTransferManager.getFileMd5(
selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": name,
"brief": "brief",
"size": size,
"md5": md5,
"tags": [],
"parentId": header.items.length !== 0 ? header.items[header.items.length - 1].uuid : null
}
console.log("begin")
Request.post("knowledge/file",
JSON.stringify(body),
function (res, data) {
console.log(res)
console.log(data)
FileTransferManager.upload(
selectedFile, data.id,
data.ticket, name)
}, function (res, data) {
console.log(res)
})
}
}
} }
} }
RowLayout { RowLayout {

View File

@ -84,83 +84,86 @@ FluArea {
} }
} }
MouseArea {
anchors.fill: row
acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: {
fileItem.parent.doubleClicked()
}
onClicked: {
if (mouse.button === Qt.RightButton) {
menu.popup()
}
}
}
ColumnLayout {
id: clickable
anchors.fill: row
RowLayout {
id: titleRow
Image {
id: icon
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
}
FluText {
id: title
font.bold: true
font.pointSize: 12
text: fileItem.title
textFormat: Text.RichText
}
}
FluText {
id: brief
visible: !fileItem.isDir
text: fileItem.brief
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
maximumLineCount: 2
textFormat: Text.RichText
}
RowLayout {
id: infoRow
visible: !fileItem.isDir
FluText {
id: date
color: "#5F5F5F"
text: fileItem.date
}
FluText {
id: size
// cast Byte size to right text size
color: "#5F5F5F"
text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed(
2) + "KB"
}
FluText {
id: pageView
color: "#5F5F5F"
text: fileItem.pageView + "浏览"
}
FluText {
id: stars
color: "#5F5F5F"
text: fileItem.stars + "收藏"
}
}
}
ColumnLayout { ColumnLayout {
id: row id: row
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 anchors.margins: 10
spacing: 10 spacing: 10
ColumnLayout {
id: clickable
anchors.fill: parent
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: {
fileItem.parent.doubleClicked()
}
onClicked: {
if (mouse.button === Qt.RightButton) {
menu.popup()
}
}
}
RowLayout {
id: titleRow
Image {
id: icon
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
}
FluText {
id: title
font.bold: true
font.pointSize: 12
text: fileItem.title
textFormat: Text.RichText
}
}
FluText {
id: brief
visible: !fileItem.isDir
text: fileItem.brief
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
maximumLineCount: 2
textFormat: Text.RichText
}
RowLayout {
id: infoRow
visible: !fileItem.isDir
FluText {
id: date
color: "#5F5F5F"
text: fileItem.date
}
FluText {
id: size
// cast Byte size to right text size
color: "#5F5F5F"
text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed(
2) + "KB"
}
FluText {
id: pageView
color: "#5F5F5F"
text: fileItem.pageView + "浏览"
}
FluText {
id: stars
color: "#5F5F5F"
text: fileItem.stars + "收藏"
}
}
}
RowLayout { RowLayout {
visible: !fileItem.isDir visible: !fileItem.isDir
Repeater { Repeater {

View File

@ -14,7 +14,8 @@ FluButton {
text: "上传" text: "上传"
onClicked: function () { onClicked: function () {
console.log("click") console.log("click")
fileDialog.open() //fileDialog.open()
popup.open()
} }
FileDialog { FileDialog {
id: fileDialog id: fileDialog
@ -52,7 +53,7 @@ FluButton {
} }
} }
Row { Column {
id: content id: content
topPadding: 14 topPadding: 14
leftPadding: 20 leftPadding: 20
@ -68,6 +69,7 @@ FluButton {
width: parent.width - parent.leftPadding - parent.rightPadding width: parent.width - parent.leftPadding - parent.rightPadding
placeholderText: "请输入简介" placeholderText: "请输入简介"
} }
Tag {}
} }
Rectangle { Rectangle {

View File

@ -11,7 +11,7 @@ FileTransferListModel::FileTransferListModel(QObject *parent)
m_roleName.insert(kSpeedRole, "speed"); m_roleName.insert(kSpeedRole, "speed");
m_roleName.insert(kPausedRole, "paused"); m_roleName.insert(kPausedRole, "paused");
m_data.append({true, "id", "name", 30, 100, 30}); //m_data.append({true, "id", "name", 30, 100, 30});
} }