diff --git a/AicsKnowledgeBase/qml/component/FileList.qml b/AicsKnowledgeBase/qml/component/FileList.qml index 9e01396..ab662a5 100644 --- a/AicsKnowledgeBase/qml/component/FileList.qml +++ b/AicsKnowledgeBase/qml/component/FileList.qml @@ -5,19 +5,29 @@ import "qrc:///AicsKnowledgeBase/qml/global" 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 +124,7 @@ Item { } fileListModel.append(modelItem) } + console.log(fileListModel) listView.currentIndex = -1 }) } @@ -140,7 +151,8 @@ Item { size: isDir ? 0 : model.size stars: isDir ? 0 : model.stars // split string to array - tags: isDir ? [] : model.tags.split(",") + tags: isDir ? [] : model.tags.length === 0 ? [] : model.tags.split( + ",") onTagClicked: { emit: search(tag) console.log(tag) @@ -158,33 +170,33 @@ Item { } 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 + } } } diff --git a/AicsKnowledgeBase/qml/page/FilePage.qml b/AicsKnowledgeBase/qml/page/FilePage.qml index dfdd14b..1d86c48 100644 --- a/AicsKnowledgeBase/qml/page/FilePage.qml +++ b/AicsKnowledgeBase/qml/page/FilePage.qml @@ -37,5 +37,7 @@ FluArea { } } - FileList {} + FileList { + autoRequest: true + } } diff --git a/AicsKnowledgeBase/qml/page/SearchPage.qml b/AicsKnowledgeBase/qml/page/SearchPage.qml index 35dcc49..d5d9761 100644 --- a/AicsKnowledgeBase/qml/page/SearchPage.qml +++ b/AicsKnowledgeBase/qml/page/SearchPage.qml @@ -18,32 +18,34 @@ FluArea { // Layout.topMargin: 20 // text: "Search" // } + + /* 按标题,内容搜索 */ - ColumnLayout{ + ColumnLayout { width: parent.width - RowLayout{ - width:parent.width - FluDropDownButton{ - id:select_model + RowLayout { + width: parent.width + FluDropDownButton { + id: select_model Layout.alignment: Qt.AlignLeft - text:"标题" - items:[ - FluMenuItem{ - text:"标题" + text: "标题" + items: [ + FluMenuItem { + text: "标题" onClicked: { select_model.text = text } }, - FluMenuItem{ - text:"内容" + FluMenuItem { + text: "内容" onClicked: { select_model.text = text } }, - FluMenuItem{ - text:"标签" + FluMenuItem { + text: "标签" onClicked: { select_model.text = text } @@ -51,91 +53,118 @@ FluArea { ] } - FluTextBox{ + FluTextBox { //placeholderText:"" Layout.fillWidth: true - } - FluIconButton{ + FluIconButton { Layout.alignment: Qt.AlignRight - iconSource:FluentIcons.Search + iconSource: FluentIcons.Search } } - //按文件类型 - RowLayout{ - id:selectFormat - width:parent.width - FluText{ + RowLayout { + id: selectFormat + width: parent.width + FluText { Layout.alignment: Qt.AlignLeft - text:"类型: " + text: "类型: " } - FluCheckBox{ - id:selectAllFormat - text:"all" - Component.onCompleted:{ + FluCheckBox { + id: selectAllFormat + text: "all" + Component.onCompleted: { clicked() } - onClicked:{ - selectVideo.checked=true - selectDoc.checked=true - selectAudio.checked=true + onClicked: { + selectVideo.checked = true + selectDoc.checked = true + selectAudio.checked = true } } - FluCheckBox{ - id:selectVideo - text:"Video" - onClicked:{ + FluCheckBox { + id: selectVideo + text: "Video" + onClicked: { selectFormat.setAllStatus() } } - FluCheckBox{ - id:selectDoc - text:"Doc" - onClicked:{ + FluCheckBox { + id: selectDoc + text: "Doc" + onClicked: { selectFormat.setAllStatus() } } - FluCheckBox{ - id:selectAudio - text:"Audio" - onClicked:{ + FluCheckBox { + id: selectAudio + text: "Audio" + onClicked: { selectFormat.setAllStatus() } } function setAllStatus() { - selectAllFormat.checked = selectVideo.checked && selectDoc.checked && selectAudio.checked + selectAllFormat.checked = selectVideo.checked + && selectDoc.checked && selectAudio.checked } } - RowLayout{ - width:parent.width + RowLayout { + width: parent.width height: 32 - FluText{ + FluText { id: tag Layout.alignment: Qt.AlignLeft - text:"标签: " + text: "标签: " } - - Tag{ + Tag { width: 290 } - } - - FluArea{ + 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 + } + } } } }