File indexing completed on 2024-12-08 07:33:44
0001 // SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 #include "devicesproxymodel.h" 0005 #include "devicesmodel.h" 0006 0007 int DevicesProxyModel::type() const 0008 { 0009 return m_type; 0010 } 0011 void DevicesProxyModel::setType(int type) 0012 { 0013 m_type = type; 0014 Q_EMIT typeChanged(); 0015 } 0016 0017 bool DevicesProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const 0018 { 0019 Q_UNUSED(source_parent) 0020 return sourceModel()->data(sourceModel()->index(source_row, 0), DevicesModel::Type).toInt() == m_type; 0021 } 0022 DevicesProxyModel::DevicesProxyModel(QObject *parent) 0023 : QSortFilterProxyModel(parent) 0024 , m_type(0) 0025 { 0026 setSortRole(DevicesModel::LastTimestamp); 0027 sort(0, Qt::DescendingOrder); 0028 } 0029 0030 #include "moc_devicesproxymodel.cpp"