AicsKnowledgeBase_client/AicsKnowledgeBase/qml/component/NoteList.qml

118 lines
4.3 KiB
QML
Raw Normal View History

2023-07-02 22:39:39 +08:00
import QtQuick 2.15
import QtQuick.Layouts
import FluentUI
import "qrc:///AicsKnowledgeBase/qml/global"
Item {
anchors.fill: parent
2023-07-07 02:38:52 +08:00
signal open(string note, string authorId)
2023-07-06 14:00:55 +08:00
signal createNote
width: parent.width - 8
property ListModel noteListModel: ListModel {
ListElement {
uuid: "1"
title: "超级无敌报错"
brief: "file:///D:/academic/2023-qtBig/AicsKnowledgeBase_client/AicsKnowledgeBase/qml/component/NoteList.qml:41:21: Unable to assign [undefined] to QString"
author: "admin"
2023-07-07 02:38:52 +08:00
authorId: "345"
2023-07-06 14:00:55 +08:00
pageView: 123
stars: 27
date: "2022-02-02"
}
ListElement {
uuid: "2"
title: "Qt布局"
brief: "锚定anchors在确定父子组件之间同级组件之间的相对位置时非常常用若使用锚定方式确定子组件与父组件之间的位置关系使用 topbottomleftright topMarginbottomMarginleftMarginrightMargin进行上下左右对齐以及对齐后的留白距离。若要使子组件在父组件的水平垂直居中使用"
author: "超级无敌长的账户名"
2023-07-07 02:38:52 +08:00
authorId: "345"
2023-07-06 14:00:55 +08:00
pageView: 123
stars: 27
date: "2022-02-02"
}
ListElement {
uuid: "2"
title: "Qt布局"
brief: "锚定anchors在确定父子组件之间同级组件之间的相对位置时非常常用若使用锚定方式确定子组件与父组件之间的位置关系使用 topbottomleftright topMarginbottomMarginleftMarginrightMargin进行上下左右对齐以及对齐后的留白距离。若要使子组件在父组件的水平垂直居中使用"
author: "超级无敌长的账户名"
2023-07-07 02:38:52 +08:00
authorId: "345"
2023-07-06 14:00:55 +08:00
pageView: 123
stars: 27
date: "2022-02-02"
}
ListElement {
uuid: "2"
title: "Qt布局"
brief: "锚定anchors在确定父子组件之间同级组件之间的相对位置时非常常用若使用锚定方式确定子组件与父组件之间的位置关系使用 topbottomleftright topMarginbottomMarginleftMarginrightMargin进行上下左右对齐以及对齐后的留白距离。若要使子组件在父组件的水平垂直居中使用"
author: "超级无敌长的账户名"
2023-07-07 02:38:52 +08:00
authorId: "345"
2023-07-06 14:00:55 +08:00
pageView: 123
stars: 27
date: "2022-02-02"
}
}
2023-07-02 22:39:39 +08:00
ListView {
id: listView
anchors.fill: parent
spacing: 8
header: noteListItemHeader
model: noteListModel
delegate: noteListItemDelegate
}
2023-07-07 04:48:06 +08:00
2023-07-02 22:39:39 +08:00
Component {
id: noteListItemHeader
Item {
id: noteListItemHeaderItem
2023-07-06 14:00:55 +08:00
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()
}
}
}
2023-07-02 22:39:39 +08:00
}
}
Component {
id: noteListItemDelegate
Rectangle {
id: noteListItemRect
width: ListView.view.width
height: 150
MouseArea {
anchors.fill: parent
onClicked: {
2023-07-07 02:38:52 +08:00
open(model.uuid, model.authorId)
2023-07-02 22:39:39 +08:00
}
}
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
2023-07-07 02:38:52 +08:00
authorId: model.authorId
2023-07-02 22:39:39 +08:00
stars: model.stars
}
}
}
function setListModel(listModel) {
listView.model = listModel
2023-07-07 04:48:06 +08:00
//console.log(listView.model.get(0).uuid)
2023-07-02 22:39:39 +08:00
}
}