File indexing completed on 2025-03-09 06:47:46
0001 /* 0002 SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "kdescendantsproxymodel_qml.h" 0008 #include <QDebug> 0009 0010 KDescendantsProxyModelQml::KDescendantsProxyModelQml(QObject *parent) 0011 : KDescendantsProxyModel(parent) 0012 { 0013 } 0014 0015 KDescendantsProxyModelQml::~KDescendantsProxyModelQml() 0016 { 0017 } 0018 0019 void KDescendantsProxyModelQml::expandChildren(int row) 0020 { 0021 QModelIndex idx = mapToSource(index(row, 0)); 0022 expandSourceIndex(idx); 0023 } 0024 0025 void KDescendantsProxyModelQml::collapseChildren(int row) 0026 { 0027 QModelIndex idx = mapToSource(index(row, 0)); 0028 collapseSourceIndex(idx); 0029 } 0030 0031 void KDescendantsProxyModelQml::toggleChildren(int row) 0032 { 0033 QModelIndex sourceIndex = mapToSource(index(row, 0)); 0034 0035 if (!sourceModel()->hasChildren(sourceIndex)) { 0036 return; 0037 } 0038 0039 if (isSourceIndexExpanded(sourceIndex)) { 0040 collapseSourceIndex(sourceIndex); 0041 } else { 0042 expandSourceIndex(sourceIndex); 0043 } 0044 } 0045 0046 #include "moc_kdescendantsproxymodel_qml.cpp"