From e10fddb1889b95ae2f5b3db66479ac528a9f96e3 Mon Sep 17 00:00:00 2001 From: wuyize Date: Fri, 7 Jul 2023 01:57:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86FileListItem?= =?UTF-8?q?=E7=9A=84=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/component/FileList.qml | 41 +---- .../qml/component/FileListItem.qml | 145 +++++++++--------- .../qml/component/UploadButton.qml | 6 +- .../src/FileTransferListModel.cpp | 2 +- 4 files changed, 80 insertions(+), 114 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/FileList.qml b/AicsKnowledgeBase/qml/component/FileList.qml index e0a0cc2..e5d4149 100644 --- a/AicsKnowledgeBase/qml/component/FileList.qml +++ b/AicsKnowledgeBase/qml/component/FileList.qml @@ -164,47 +164,8 @@ Item { } } } - FluButton { - id: uploadIcon + UploadButton { 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 { diff --git a/AicsKnowledgeBase/qml/component/FileListItem.qml b/AicsKnowledgeBase/qml/component/FileListItem.qml index 68c7053..862f8c6 100644 --- a/AicsKnowledgeBase/qml/component/FileListItem.qml +++ b/AicsKnowledgeBase/qml/component/FileListItem.qml @@ -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 { id: row anchors.fill: parent anchors.margins: 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 { visible: !fileItem.isDir Repeater { diff --git a/AicsKnowledgeBase/qml/component/UploadButton.qml b/AicsKnowledgeBase/qml/component/UploadButton.qml index 3b3da65..7605c86 100644 --- a/AicsKnowledgeBase/qml/component/UploadButton.qml +++ b/AicsKnowledgeBase/qml/component/UploadButton.qml @@ -14,7 +14,8 @@ FluButton { text: "上传" onClicked: function () { console.log("click") - fileDialog.open() + //fileDialog.open() + popup.open() } FileDialog { id: fileDialog @@ -52,7 +53,7 @@ FluButton { } } - Row { + Column { id: content topPadding: 14 leftPadding: 20 @@ -68,6 +69,7 @@ FluButton { width: parent.width - parent.leftPadding - parent.rightPadding placeholderText: "请输入简介" } + Tag {} } Rectangle { diff --git a/AicsKnowledgeBase/src/FileTransferListModel.cpp b/AicsKnowledgeBase/src/FileTransferListModel.cpp index 46644e4..069efa8 100644 --- a/AicsKnowledgeBase/src/FileTransferListModel.cpp +++ b/AicsKnowledgeBase/src/FileTransferListModel.cpp @@ -11,7 +11,7 @@ FileTransferListModel::FileTransferListModel(QObject *parent) m_roleName.insert(kSpeedRole, "speed"); m_roleName.insert(kPausedRole, "paused"); - m_data.append({true, "id", "name", 30, 100, 30}); + //m_data.append({true, "id", "name", 30, 100, 30}); }