1 /* 2 SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #include "kdescendantsproxymodel_qml.h" 8 #include <QDebug> 9 KDescendantsProxyModelQml(QObject * parent)10KDescendantsProxyModelQml::KDescendantsProxyModelQml(QObject *parent) 11 : KDescendantsProxyModel(parent) 12 { 13 } 14 ~KDescendantsProxyModelQml()15KDescendantsProxyModelQml::~KDescendantsProxyModelQml() 16 { 17 } 18 expandChildren(int row)19void KDescendantsProxyModelQml::expandChildren(int row) 20 { 21 QModelIndex idx = mapToSource(index(row, 0)); 22 expandSourceIndex(idx); 23 } 24 collapseChildren(int row)25void KDescendantsProxyModelQml::collapseChildren(int row) 26 { 27 QModelIndex idx = mapToSource(index(row, 0)); 28 collapseSourceIndex(idx); 29 } 30 toggleChildren(int row)31void KDescendantsProxyModelQml::toggleChildren(int row) 32 { 33 QModelIndex sourceIndex = mapToSource(index(row, 0)); 34 35 if (!sourceModel()->hasChildren(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