File indexing completed on 2024-11-24 04:50:43

0001 // SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com>
0002 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
0003 //
0004 // SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 #include "sortedcollectionproxymodel.h"
0007 
0008 SortedCollectionProxModel::SortedCollectionProxModel(QObject *parent)
0009     : Akonadi::CollectionFilterProxyModel(parent)
0010 {
0011 }
0012 
0013 bool SortedCollectionProxModel::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const
0014 {
0015     const auto leftHasChildren = sourceModel()->hasChildren(sourceLeft);
0016     const auto rightHasChildren = sourceModel()->hasChildren(sourceRight);
0017     if (leftHasChildren && !rightHasChildren) {
0018         return false;
0019     } else if (!leftHasChildren && rightHasChildren) {
0020         return true;
0021     }
0022 
0023     return Akonadi::CollectionFilterProxyModel::lessThan(sourceLeft, sourceRight);
0024 }