From a65e4af382710e71b4e10acd807cf4397601cf40 Mon Sep 17 00:00:00 2001 From: karlis <2995621482@qq.com> Date: Fri, 7 Jul 2023 05:45:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9NoteList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/component/NoteList.qml | 109 ++++++++++--------- AicsKnowledgeBase/qml/page/ContentPage.qml | 5 +- 2 files changed, 59 insertions(+), 55 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/NoteList.qml b/AicsKnowledgeBase/qml/component/NoteList.qml index 008b8b1..12b2ed7 100644 --- a/AicsKnowledgeBase/qml/component/NoteList.qml +++ b/AicsKnowledgeBase/qml/component/NoteList.qml @@ -1,5 +1,7 @@ import QtQuick 2.15 import QtQuick.Layouts +import QtQuick.Controls +import QtQuick.Window import FluentUI import "qrc:///AicsKnowledgeBase/qml/global" @@ -50,68 +52,67 @@ Item { date: "2022-02-02" } } - ListView { - id: listView - anchors.fill: parent - spacing: 8 - header: noteListItemHeader - model: noteListModel - delegate: noteListItemDelegate + + RowLayout { + height: 48 + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: 10 + anchors.rightMargin: 10 + FluText { + text: "笔记列表" + font.pixelSize: 18 + font.bold: true + } + FluButton { + id: createNoteButton + text: "新建笔记" + Layout.alignment: Qt.AlignRight + onClicked: { + createNote() + } + } } - Component { - id: noteListItemHeader - Item { - id: noteListItemHeaderItem - width: ListView.view.width - height: 48 - RowLayout { - width: parent.width - FluText { - text: "笔记列表" - font.pixelSize: 18 - font.bold: true - } - FluButton { - id: createNoteButton - text: "新建笔记" - Layout.alignment: Qt.AlignRight - onClicked: { - createNote() + FluScrollablePage { + anchors.fill: parent + anchors.topMargin: 50 + ColumnLayout { + Layout.fillWidth: true + spacing: 8 + Repeater { + id: repeater + model: noteListModel + delegate: Rectangle { + id: noteListItemRect + Layout.fillWidth: true + height: 150 + MouseArea { + anchors.fill: parent + onClicked: { + open(model.uuid, model.authorId) + } + } + NoteListItem { + id: noteListItem + uuid: model.uuid + width: parent.width + height: parent.height + title: model.title + date: model.date + brief: model.brief + pageView: model.pageView + author: model.author + authorId: model.authorId + stars: model.stars } } } } } - Component { - id: noteListItemDelegate - Rectangle { - id: noteListItemRect - width: ListView.view.width - height: 150 - MouseArea { - anchors.fill: parent - onClicked: { - open(model.uuid, model.authorId) - } - } - NoteListItem { - id: noteListItem - uuid: model.uuid - width: parent.width - height: parent.height - title: model.title - date: model.date - brief: model.brief - pageView: model.pageView - author: model.author - authorId: model.authorId - stars: model.stars - } - } - } + function setListModel(listModel) { - listView.model = listModel + repeater.model = listModel //console.log(listView.model.get(0).uuid) } } diff --git a/AicsKnowledgeBase/qml/page/ContentPage.qml b/AicsKnowledgeBase/qml/page/ContentPage.qml index fd11472..8dddd34 100644 --- a/AicsKnowledgeBase/qml/page/ContentPage.qml +++ b/AicsKnowledgeBase/qml/page/ContentPage.qml @@ -14,6 +14,8 @@ import "qrc:///AicsKnowledgeBase/qml/global" FluArea { property ListModel noteListModel2: ListModel {} Popup { + x: parent.width - width + implicitHeight: parent.height id: popup modal: true //模态, 为 true后弹出窗口会叠加一个独特的背景调光效果 focus: true //焦点, 当弹出窗口实际接收到焦点时,activeFocus将为真 @@ -24,12 +26,13 @@ FluArea { color: Qt.rgba(0, 0, 0, 0) //背景为无色 } FluArea { + width: 350 height: 500 backgroundColor: "#f9f9f9" NoteList { id: noteList - noteListModel: noteListModel2 + //noteListModel: noteListModel2 onOpen: function handle(noteId, authorId) { emit: SignalFileOperation.openNote(noteId, authorId) popup.close()