mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-22 19:00:07 +08:00
update
This commit is contained in:
parent
295dcf02c4
commit
17bfff2346
@ -2394,22 +2394,22 @@ Some contents...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="184"/>
|
||||
<location filename="qml/page/T_TreeView.qml" line="185"/>
|
||||
<source>Title</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="188"/>
|
||||
<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="192"/>
|
||||
<location filename="qml/page/T_TreeView.qml" line="193"/>
|
||||
<source>Avatar</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="196"/>
|
||||
<location filename="qml/page/T_TreeView.qml" line="197"/>
|
||||
<source>Address</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -2504,22 +2504,22 @@ Some contents...</source>
|
||||
<translation type="obsolete">共计选中%1条数据</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="184"/>
|
||||
<location filename="qml/page/T_TreeView.qml" line="185"/>
|
||||
<source>Title</source>
|
||||
<translation type="unfinished">标题</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="196"/>
|
||||
<location filename="qml/page/T_TreeView.qml" line="197"/>
|
||||
<source>Address</source>
|
||||
<translation type="unfinished">地址</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="192"/>
|
||||
<location filename="qml/page/T_TreeView.qml" line="193"/>
|
||||
<source>Avatar</source>
|
||||
<translation type="unfinished">头像</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="188"/>
|
||||
<location filename="qml/page/T_TreeView.qml" line="189"/>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished">名称</translation>
|
||||
</message>
|
||||
|
@ -28,7 +28,7 @@ FluContentPage {
|
||||
}
|
||||
const dig = (path = '0', level = 5) => {
|
||||
const list = [];
|
||||
for (let i = 0; i < 5; i += 1) {
|
||||
for (let i = 0; i < 4; i += 1) {
|
||||
const key = `${path}-${i}`;
|
||||
const treeNode = {
|
||||
title: key,
|
||||
@ -148,7 +148,8 @@ FluContentPage {
|
||||
text: "print selection model"
|
||||
onClicked: {
|
||||
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++){
|
||||
const newObj = Object.assign({}, data[i].data);
|
||||
delete newObj["__parent"];
|
||||
|
@ -113,15 +113,7 @@ void FluTreeModel::checkRow(int row, bool checked) {
|
||||
itemData->_checked = checked;
|
||||
}
|
||||
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) {
|
||||
@ -272,3 +264,13 @@ void FluTreeModel::allCollapse() {
|
||||
_rows = _root->_children;
|
||||
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 {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int, dataSourceSize)
|
||||
Q_PROPERTY_AUTO(QList<FluTreeNode *>, selectionModel)
|
||||
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
|
||||
QML_NAMED_ELEMENT(FluTreeModel)
|
||||
QML_ADDED_IN_MINOR_VERSION(1)
|
||||
@ -141,6 +140,8 @@ public:
|
||||
|
||||
Q_INVOKABLE void allCollapse();
|
||||
|
||||
Q_INVOKABLE QVariant selectionModel();
|
||||
|
||||
private:
|
||||
QList<FluTreeNode *> _rows;
|
||||
QList<FluTreeNode *> _dataSource;
|
||||
|
@ -12,7 +12,6 @@ Rectangle {
|
||||
property int cellHeight: 30
|
||||
property int depthPadding: 15
|
||||
property bool checkable: false
|
||||
property alias selectionModel: tree_model.selectionModel
|
||||
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 selectedBorderColor: FluTheme.primaryColor
|
||||
@ -739,4 +738,7 @@ Rectangle {
|
||||
d.editPosition = undefined
|
||||
d.editDelegate = undefined
|
||||
}
|
||||
function selectionModel(){
|
||||
return tree_model.selectionModel()
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ Rectangle {
|
||||
property int cellHeight: 30
|
||||
property int depthPadding: 15
|
||||
property bool checkable: false
|
||||
property alias selectionModel: tree_model.selectionModel
|
||||
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 selectedBorderColor: FluTheme.primaryColor
|
||||
@ -739,4 +738,7 @@ Rectangle {
|
||||
d.editPosition = undefined
|
||||
d.editDelegate = undefined
|
||||
}
|
||||
function selectionModel(){
|
||||
return tree_model.selectionModel()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user