Compare commits

..

3 Commits

Author SHA1 Message Date
朱子楚\zhuzi
ecd13a9cca update 2024-04-15 00:11:41 +08:00
朱子楚\zhuzi
17bfff2346 update 2024-04-14 23:58:15 +08:00
朱子楚\zhuzi
295dcf02c4 update 2024-04-14 23:09:41 +08:00
10 changed files with 54 additions and 101 deletions

View File

@ -2394,25 +2394,25 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="230"/> <location filename="qml/page/T_TreeView.qml" line="185"/>
<source>Title</source> <source>Title</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="238"/> <location filename="qml/page/T_TreeView.qml" line="189"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TreeView.qml" line="193"/>
<source>Avatar</source> <source>Avatar</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="242"/> <location filename="qml/page/T_TreeView.qml" line="197"/>
<source>Address</source> <source>Address</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="qml/page/T_TreeView.qml" line="234"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>T_Typography</name> <name>T_Typography</name>

View File

@ -2504,22 +2504,22 @@ Some contents...</source>
<translation type="obsolete">%1</translation> <translation type="obsolete">%1</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="230"/> <location filename="qml/page/T_TreeView.qml" line="185"/>
<source>Title</source> <source>Title</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="242"/> <location filename="qml/page/T_TreeView.qml" line="197"/>
<source>Address</source> <source>Address</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="238"/> <location filename="qml/page/T_TreeView.qml" line="193"/>
<source>Avatar</source> <source>Avatar</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="234"/> <location filename="qml/page/T_TreeView.qml" line="189"/>
<source>Name</source> <source>Name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -10,7 +10,6 @@ FluContentPage {
title: qsTr("TreeView") title: qsTr("TreeView")
function treeData(){ function treeData(){
const names = ["孙悟空", "猪八戒", "沙和尚", "唐僧","白骨夫人","金角大王","熊山君","黄风怪","银角大王"] const names = ["孙悟空", "猪八戒", "沙和尚", "唐僧","白骨夫人","金角大王","熊山君","黄风怪","银角大王"]
function getRandomName(){ function getRandomName(){
@ -29,7 +28,7 @@ FluContentPage {
} }
const dig = (path = '0', level = 5) => { const dig = (path = '0', level = 5) => {
const list = []; const list = [];
for (let i = 0; i < 5; i += 1) { for (let i = 0; i < 4; i += 1) {
const key = `${path}-${i}`; const key = `${path}-${i}`;
const treeNode = { const treeNode = {
title: key, title: key,
@ -48,67 +47,6 @@ FluContentPage {
return dig(); return dig();
} }
// Row{
// id: layout_column
// spacing: 12
// width: 340
// anchors{
// top:parent.top
// left: parent.left
// leftMargin: 10
// bottom:parent.bottom
// bottomMargin: 20
// }
// RowLayout{
// spacing: 10
// FluText{
// text: "cellHeight:"
// Layout.alignment: Qt.AlignVCenter
// }
// FluSlider{
// id: slider_cell_height
// value: 30
// from: 30
// to:100
// }
// }
// RowLayout{
// spacing: 10
// FluText{
// text: "depthPadding:"
// Layout.alignment: Qt.AlignVCenter
// }
// FluSlider{
// id: slider_depth_padding
// value: 15
// from: 15
// to:100
// }
// }
// FluToggleSwitch{
// id: switch_showline
// text:"showLine"
// checked: false
// }
// FluToggleSwitch{
// id: switch_checkable
// text:"checkable"
// checked: false
// }
// FluButton{
// text: "all expand"
// onClicked: {
// tree_view.allExpand()
// }
// }
// FluButton{
// text: "all collapse"
// onClicked: {
// tree_view.allCollapse()
// }
// }
// }
Component{ Component{
id:com_avatar id:com_avatar
Item{ Item{
@ -206,7 +144,21 @@ FluContentPage {
} }
} }
} }
FluButton{
text: "print selection model"
onClicked: {
var printData = []
var data = tree_view.selectionModel();
console.debug(data.length)
for(var i = 0; i <= data.length-1 ; i++){
const newObj = Object.assign({}, data[i].data);
delete newObj["__parent"];
delete newObj["children"];
printData.push(newObj)
}
console.debug(JSON.stringify(printData))
}
}
} }
} }
@ -225,6 +177,9 @@ FluContentPage {
showLine: switch_showline.checked showLine: switch_showline.checked
checkable:switch_checkable.checked checkable:switch_checkable.checked
depthPadding: slider_depth_padding.value depthPadding: slider_depth_padding.value
onCurrentChanged: {
showInfo(current.data.title)
}
columnSource:[ columnSource:[
{ {
title: qsTr("Title"), title: qsTr("Title"),

View File

@ -161,19 +161,12 @@ void FluFrameless::componentComplete() {
if (!isCompositionEnabled()) { if (!isCompositionEnabled()) {
offsetSize = 0; offsetSize = 0;
} }
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!isMaximum) { if (!isMaximum) {
clientRect->top = originalTop + offsetSize; clientRect->top = originalTop + offsetSize;
clientRect->bottom = originalBottom; clientRect->bottom = originalBottom;
clientRect->left = originalLeft; clientRect->left = originalLeft;
clientRect->right = originalRight; clientRect->right = originalRight;
} }
#else
clientRect->top = originalTop + offsetSize;
clientRect->bottom = originalBottom;
clientRect->left = originalLeft;
clientRect->right = originalRight;
#endif
_setMaximizeHovered(false); _setMaximizeHovered(false);
*result = WVR_REDRAW; *result = WVR_REDRAW;
return true; return true;

View File

@ -113,15 +113,7 @@ void FluTreeModel::checkRow(int row, bool checked) {
itemData->_checked = checked; itemData->_checked = checked;
} }
Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0)); Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0));
QList<FluTreeNode *> data;
foreach (auto item, _dataSource) {
if (!item->hasChildren()) {
if (item->_checked) {
data.append(item);
}
}
}
selectionModel(data);
} }
void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) { void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) {
@ -272,3 +264,13 @@ void FluTreeModel::allCollapse() {
_rows = _root->_children; _rows = _root->_children;
endResetModel(); endResetModel();
} }
QVariant FluTreeModel::selectionModel(){
QList<FluTreeNode *> data;
foreach (auto item, _dataSource) {
if (item->checked()) {
data.append(item);
}
}
return QVariant::fromValue(data);
}

View File

@ -89,7 +89,6 @@ public:
class FluTreeModel : public QAbstractItemModel { class FluTreeModel : public QAbstractItemModel {
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(int, dataSourceSize) Q_PROPERTY_AUTO(int, dataSourceSize)
Q_PROPERTY_AUTO(QList<FluTreeNode *>, selectionModel)
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource) Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
QML_NAMED_ELEMENT(FluTreeModel) QML_NAMED_ELEMENT(FluTreeModel)
QML_ADDED_IN_MINOR_VERSION(1) QML_ADDED_IN_MINOR_VERSION(1)
@ -141,6 +140,8 @@ public:
Q_INVOKABLE void allCollapse(); Q_INVOKABLE void allCollapse();
Q_INVOKABLE QVariant selectionModel();
private: private:
QList<FluTreeNode *> _rows; QList<FluTreeNode *> _rows;
QList<FluTreeNode *> _dataSource; QList<FluTreeNode *> _dataSource;

View File

@ -80,6 +80,7 @@ FluButton {
id:container id:container
width: 300 width: 300
height: 360 height: 360
radius: 4
color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1) color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
@ -613,7 +614,7 @@ FluButton {
} }
background: Item{ background: Item{
FluShadow{ FluShadow{
radius: 5 radius: 4
} }
} }
function showPopup() { function showPopup() {

View File

@ -710,9 +710,6 @@ Rectangle {
} }
} }
} }
function selectionModel(){
return tree_model.selectionModel
}
function count(){ function count(){
return tree_model.dataSourceSize return tree_model.dataSourceSize
} }
@ -741,4 +738,7 @@ Rectangle {
d.editPosition = undefined d.editPosition = undefined
d.editDelegate = undefined d.editDelegate = undefined
} }
function selectionModel(){
return tree_model.selectionModel()
}
} }

View File

@ -79,6 +79,7 @@ FluButton {
id:container id:container
width: 300 width: 300
height: 360 height: 360
radius: 4
color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1) color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
@ -612,7 +613,7 @@ FluButton {
} }
background: Item{ background: Item{
FluShadow{ FluShadow{
radius: 5 radius: 4
} }
} }
function showPopup() { function showPopup() {

View File

@ -710,9 +710,6 @@ Rectangle {
} }
} }
} }
function selectionModel(){
return tree_model.selectionModel
}
function count(){ function count(){
return tree_model.dataSourceSize return tree_model.dataSourceSize
} }
@ -741,4 +738,7 @@ Rectangle {
d.editPosition = undefined d.editPosition = undefined
d.editDelegate = undefined d.editDelegate = undefined
} }
function selectionModel(){
return tree_model.selectionModel()
}
} }