File indexing completed on 2024-02-25 16:44:36

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "directoryroomsproxymodel.h"
0008 #include "directoryroomsmodel.h"
0009 
0010 DirectoryRoomsProxyModel::DirectoryRoomsProxyModel(QAbstractListModel *model, QObject *parent)
0011     : SearchTreeBaseFilterProxyModel(model, parent)
0012 {
0013 }
0014 
0015 DirectoryRoomsProxyModel::~DirectoryRoomsProxyModel() = default;
0016 
0017 bool DirectoryRoomsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
0018 {
0019     const int leftColumn{left.column()};
0020     if (leftColumn == DirectoryRoomsModel::LastMessageStr) {
0021         const QModelIndex leftMessageModelIndex = sourceModel()->index(left.row(), DirectoryRoomsModel::LastMessageDateTime);
0022         const QModelIndex rightMessageModelIndex = sourceModel()->index(right.row(), DirectoryRoomsModel::LastMessageDateTime);
0023         return SearchTreeBaseFilterProxyModel::lessThan(leftMessageModelIndex, rightMessageModelIndex);
0024     } else if (leftColumn == DirectoryRoomsModel::CreatedStr) {
0025         const QModelIndex leftMessageModelIndex = sourceModel()->index(left.row(), DirectoryRoomsModel::CreatedDateTime);
0026         const QModelIndex rightMessageModelIndex = sourceModel()->index(right.row(), DirectoryRoomsModel::CreatedDateTime);
0027         return SearchTreeBaseFilterProxyModel::lessThan(leftMessageModelIndex, rightMessageModelIndex);
0028     }
0029     return SearchTreeBaseFilterProxyModel::lessThan(left, right);
0030 }
0031 
0032 #include "moc_directoryroomsproxymodel.cpp"