| 1 | /* |
|---|---|
| 2 | SPDX-FileCopyrightText: 2020 Marco Martin <[email protected]> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #include "kdescendantsproxymodel_qml.h" |
| 8 | #include <QDebug> |
| 9 | |
| 10 | KDescendantsProxyModelQml::KDescendantsProxyModelQml(QObject *parent) |
| 11 | : KDescendantsProxyModel(parent) |
| 12 | { |
| 13 | } |
| 14 | |
| 15 | KDescendantsProxyModelQml::~KDescendantsProxyModelQml() |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | void KDescendantsProxyModelQml::expandChildren(int row) |
| 20 | { |
| 21 | QModelIndex idx = mapToSource(proxyIndex: index(row, 0)); |
| 22 | expandSourceIndex(sourceIndex: idx); |
| 23 | } |
| 24 | |
| 25 | void KDescendantsProxyModelQml::collapseChildren(int row) |
| 26 | { |
| 27 | QModelIndex idx = mapToSource(proxyIndex: index(row, 0)); |
| 28 | collapseSourceIndex(sourceIndex: idx); |
| 29 | } |
| 30 | |
| 31 | void KDescendantsProxyModelQml::toggleChildren(int row) |
| 32 | { |
| 33 | QModelIndex sourceIndex = mapToSource(proxyIndex: index(row, 0)); |
| 34 | |
| 35 | if (!sourceModel()->hasChildren(parent: sourceIndex)) { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | if (isSourceIndexExpanded(sourceIndex)) { |
| 40 | collapseSourceIndex(sourceIndex); |
| 41 | } else { |
| 42 | expandSourceIndex(sourceIndex); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | #include "moc_kdescendantsproxymodel_qml.cpp" |
| 47 |
