Merge remote-tracking branch 'origin/main' into main

main
wuyize 2023-07-05 21:14:55 +08:00
commit f65f9f3dbb
7 changed files with 355 additions and 67 deletions

View File

@ -2,22 +2,33 @@ import QtQuick 2.15
import QtQuick.Layouts
import FluentUI
import "qrc:///AicsKnowledgeBase/qml/global"
import SignalFileOperation 1.0
Item {
anchors.fill: parent
signal search(string tag)
signal open(string file)
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 {
id: listView
anchors.fill: parent
spacing: 10
header: disableHeader ? null :fileListItemHeader
header: disableHeader ? null : fileListItemHeader
model: fileListModel
delegate: fileListItemDelegate
Component.onCompleted: {
update()
if (autoRequest) {
update()
} else {
listView.model = dataModel
}
}
}
@ -114,6 +125,7 @@ Item {
}
fileListModel.append(modelItem)
}
console.log(fileListModel)
listView.currentIndex = -1
})
}
@ -140,7 +152,9 @@ Item {
size: isDir ? 0 : model.size
stars: isDir ? 0 : model.stars
// split string to array
tags: isDir ? [] : model.tags.split(",")
tags: isDir ? [] : model.tags === null
|| model.tags === undefined
|| model.tags === "" ? [] : model.tags.split(",")
onTagClicked: {
emit: search(tag)
console.log(tag)
@ -151,40 +165,40 @@ Item {
if (model.isDir) {
listView.headerItem.add(model.title, model.uuid)
} else {
emit: open(model.uuid)
emit: SignalFileOperation.open(model.uuid)
}
}
}
}
ListModel {
id: fileListModel
ListElement {
title: "File 1"
isDir: true
brief: "This is a test file"
type: "FOLDER"
}
ListElement {
uid: "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 {
uid: "3"
title: "File 3"
isDir: false
brief: "This is a test file"
type: "PPT"
date: "2020-09-09"
pageView: 100
size: 10200000022
stars: 10
}
ListElement {
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
}
}
}

View File

@ -0,0 +1,176 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Basic
import FluentUI
Rectangle {
id: input
width: 300
height: 32
radius: 5
clip: true
border.color: textInput.activeFocus ? "#268CDC":"#979592" //gray100
ListModel { id: tagListModel }
property ListModel tagList: tagListModel
Row {
x: 5
height: parent.height
spacing: 5
Row {
id: rowTag
anchors.verticalCenter: parent.verticalCenter
spacing: 5
Repeater {
model: tagListModel
Loader {
sourceComponent: tagItem
Component.onCompleted: {
item.closeClicked.connect(function(){
tagListModel.remove(index)
})
item.tag = Qt.binding(function(){return tag})
}
}
}
}
Item {
width: input.width - rowTag.width
height: parent.height
TextField {
id:textInput
placeholderText: qsTr("按回车键Enter创建标签")
onFocusChanged: {
text =""
}
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 15
clip: true
background: Rectangle {
}
Keys.onReturnPressed: {
var presetsTags = ["前端","后端","数据库"]
if (text.length === 0)
return
if(presetsTags.indexOf(text) === -1){
text = ""
return
}
tagListModel.append({"tag": text})
//console.log(tagListModel.get(0))
text = ""
}
Keys.onPressed: {
if (event.key === Qt.Key_Backspace) {
if (text.length === 0 && tagListModel.count) {
tagListModel.remove(tagListModel.count-1)
}
}
}
}
}
}
property Component tagItem:
Rectangle {
id: rootTagItem
property alias tag: tagText.text
signal closeClicked()
width: content.width
height: 25
radius: 5
color: "#00aeec"
border.color: "#00aeec"
MouseArea {
id: mouseArea
property bool hovered: false
anchors.fill: parent
hoverEnabled: true
onEntered: hovered = true
onExited: hovered = false
Row {
id: content
anchors.verticalCenter: parent.verticalCenter
height: rootTagItem.height
Item { width: 5; height: 1 }
Text {
id: tagText
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: rootTagItem.height * 0.5
text: "Hello"
color: "white"
}
Item { visible: mouseArea.hovered; width: 5; height: 1 }
Item {
anchors.verticalCenter: parent.verticalCenter
width: mouseArea.hovered ? 15 : 0
height: rootTagItem.height
visible: mouseArea.hovered
Behavior on width {
NumberAnimation {duration: 100}
}
Behavior on visible {
NumberAnimation {duration: 100}
}
Rectangle {
width: height
height: parent.height * 0.6
anchors.centerIn: parent
radius: height
color: closeMouseArea.pressed ? "gray" : "red"
visible: closeMouseArea.hovered
}
Text {
anchors.centerIn: parent
text: "×"
color: "white"
}
MouseArea {
id: closeMouseArea
property bool hovered: false
anchors.fill: parent
hoverEnabled: true
onEntered: hovered = true
onExited: hovered = false
onCanceled: hovered = false
onClicked: rootTagItem.closeClicked()
}
}
Item { width: 5; height: 1 }
}
}
}
}

View File

@ -0,0 +1,8 @@
pragma Singleton
import QtQuick
QtObject {
signal open(string file)
signal openNote(string note)
}

View File

@ -6,12 +6,14 @@ import QtQuick.Controls.Basic
import QtWebEngine 1.2
import FluentUI
import AicsKB.FileTransferManager
import SignalFileOperation 1.0
import "qrc:///AicsKnowledgeBase/qml/page"
FluArea {
id: content_area
paddings: 0
backgroundColor: "#f9f9f9"
visible: false
property string type: ""
property string knowledgeFileId
signal download(string knowledgeFileId)
@ -23,6 +25,13 @@ FluArea {
// bottom: 10
// left: 10
// }
Connections {
target: SignalFileOperation
function onOpen(file) {
content_area.visible = true
}
}
FluScrollablePage {
id: content_page
anchors.fill: parent

View File

@ -64,5 +64,7 @@ FluArea {
}
}
FileList {}
FileList {
autoRequest: true
}
}

View File

@ -4,6 +4,7 @@ import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Basic
import FluentUI
import "qrc:///AicsKnowledgeBase/qml/global"
import "qrc:///AicsKnowledgeBase/qml/component"
FluArea {
@ -20,48 +21,70 @@ FluArea {
// }
/*
*/
*/
ColumnLayout{
width: parent.width
RowLayout{
width:parent.width
FluDropDownButton{
id:select_model
Layout.alignment: Qt.AlignLeft
text:"标题"
items:[
FluMenuItem{
text:"标题"
onClicked: {
select_model.text = text
}
},
FluMenuItem{
text:"内容"
onClicked: {
select_model.text = text
}
},
FluMenuItem{
text:"标签"
onClicked: {
select_model.text = text
}
}
]
}
// FluDropDownButton{
// id:select_model
// Layout.alignment: Qt.AlignLeft
// text:""
// items:[
// FluMenuItem{
// text:""
// onClicked: {
// select_model.text = text
// }
// },
// FluMenuItem{
// text:""
// onClicked: {
// select_model.text = text
// }
// },
// FluMenuItem{
// text:""
// onClicked: {
// select_model.text = text
// }
// }
// ]
// }
FluTextBox{
//placeholderText:""
placeholderText:"对标题进行搜索……"
Layout.fillWidth: true
}
FluIconButton{
Layout.alignment: Qt.AlignRight
iconSource:FluentIcons.Search
}
}
onClicked:{
var allTags = inputTags.getAllTags(tags.tagList)
var allTagId =[]
console.log(allTags)
for (var i = 0; i < allTags.length; i++) {
var url = "?name="
url = url + allTags[i]
console.log(url)
Request.get(url,
function(result, data){
allTagId.push()
}
)
}
}
}
}
FluCheckBox{
id:searchTitleAndContent
text:"同时搜索简介和内容"
}
//
RowLayout{
@ -102,7 +125,7 @@ FluArea {
id:selectAudio
text:"Audio"
onClicked:{
selectFormat.setAllStatus()
selectFormat.setAllStatus()
}
}
@ -111,15 +134,69 @@ FluArea {
}
}
RowLayout{
id:inputTags
width:parent.width
height: 32
FluText{
Layout.alignment: Qt.AlignLeft
text:"标签: "
}
FluArea{
Tag{
id:tags
width: 290
}
function getAllTags(tagList){
var allTags=[];
for (var i = 0; i < tagList.count; i++) {
var item = tagList.get(i);
allTags.push(item.tag)
}
return allTags
//console.log(allTags)
}
}
FluArea {
backgroundColor: "#f9f9f9"
border.width: 0
width: parent.width
height: 500
FileList{
FileList {
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
}
}
}
}
}

View File

@ -54,6 +54,8 @@ int main(int argc, char *argv[])
qmlRegisterSingletonInstance<FileTransferManager>("AicsKB.FileTransferManager", 1, 0, "FileTransferManager",
fileTransferManager);
qmlRegisterSingletonType(QUrl("qrc:/AicsKnowledgeBase/qml/global/SignalFileOperation.qml"), "SignalFileOperation", 1, 0,
"SignalFileOperation");
const QUrl url(u"qrc:/AicsKnowledgeBase/qml/App.qml"_qs);
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,