mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-26 13:27:05 +08:00
update
This commit is contained in:
parent
295dcf02c4
commit
17bfff2346
@ -2394,22 +2394,22 @@ Some contents...</source>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TreeView.qml" line="184"/>
|
<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="188"/>
|
<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>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TreeView.qml" line="192"/>
|
<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="196"/>
|
<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>
|
||||||
|
@ -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="184"/>
|
<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="196"/>
|
<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="192"/>
|
<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="188"/>
|
<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>
|
||||||
|
@ -28,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,
|
||||||
@ -148,7 +148,8 @@ FluContentPage {
|
|||||||
text: "print selection model"
|
text: "print selection model"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var printData = []
|
var printData = []
|
||||||
var data = tree_view.selectionModel
|
var data = tree_view.selectionModel();
|
||||||
|
console.debug(data.length)
|
||||||
for(var i = 0; i <= data.length-1 ; i++){
|
for(var i = 0; i <= data.length-1 ; i++){
|
||||||
const newObj = Object.assign({}, data[i].data);
|
const newObj = Object.assign({}, data[i].data);
|
||||||
delete newObj["__parent"];
|
delete newObj["__parent"];
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -12,7 +12,6 @@ Rectangle {
|
|||||||
property int cellHeight: 30
|
property int cellHeight: 30
|
||||||
property int depthPadding: 15
|
property int depthPadding: 15
|
||||||
property bool checkable: false
|
property bool checkable: false
|
||||||
property alias selectionModel: tree_model.selectionModel
|
|
||||||
property color lineColor: FluTheme.dividerColor
|
property color lineColor: FluTheme.dividerColor
|
||||||
property color borderColor: FluTheme.dark ? Qt.rgba(37/255,37/255,37/255,1) : Qt.rgba(228/255,228/255,228/255,1)
|
property color borderColor: FluTheme.dark ? Qt.rgba(37/255,37/255,37/255,1) : Qt.rgba(228/255,228/255,228/255,1)
|
||||||
property color selectedBorderColor: FluTheme.primaryColor
|
property color selectedBorderColor: FluTheme.primaryColor
|
||||||
@ -739,4 +738,7 @@ Rectangle {
|
|||||||
d.editPosition = undefined
|
d.editPosition = undefined
|
||||||
d.editDelegate = undefined
|
d.editDelegate = undefined
|
||||||
}
|
}
|
||||||
|
function selectionModel(){
|
||||||
|
return tree_model.selectionModel()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ Rectangle {
|
|||||||
property int cellHeight: 30
|
property int cellHeight: 30
|
||||||
property int depthPadding: 15
|
property int depthPadding: 15
|
||||||
property bool checkable: false
|
property bool checkable: false
|
||||||
property alias selectionModel: tree_model.selectionModel
|
|
||||||
property color lineColor: FluTheme.dividerColor
|
property color lineColor: FluTheme.dividerColor
|
||||||
property color borderColor: FluTheme.dark ? Qt.rgba(37/255,37/255,37/255,1) : Qt.rgba(228/255,228/255,228/255,1)
|
property color borderColor: FluTheme.dark ? Qt.rgba(37/255,37/255,37/255,1) : Qt.rgba(228/255,228/255,228/255,1)
|
||||||
property color selectedBorderColor: FluTheme.primaryColor
|
property color selectedBorderColor: FluTheme.primaryColor
|
||||||
@ -739,4 +738,7 @@ Rectangle {
|
|||||||
d.editPosition = undefined
|
d.editPosition = undefined
|
||||||
d.editDelegate = undefined
|
d.editDelegate = undefined
|
||||||
}
|
}
|
||||||
|
function selectionModel(){
|
||||||
|
return tree_model.selectionModel()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user