File indexing completed on 2024-05-05 04:51:45

0001 /* 
0002     SPDX-FileCopyrightText: 2009 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
0003     SPDX-FileCopyrightText: 2011 Michal Malek <michalm@jabster.pl>
0004     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef K3BDIRPROXYMODEL_H
0010 #define K3BDIRPROXYMODEL_H
0011 
0012 #include <QSortFilterProxyModel>
0013 
0014 /**
0015  * This class is used to show only directories from a specific model.
0016  * It is used in the dir panel (of StandardView) to show a directory
0017  * tree.
0018  *
0019  * @author Gustavo Pichorim Boiko
0020  */
0021 namespace K3b {
0022 class DirProxyModel : public QSortFilterProxyModel
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     explicit DirProxyModel( QObject *parent = 0 );
0028     ~DirProxyModel() override;
0029 
0030 protected:
0031     /**
0032      * This function (reimplemented from QSortFilterProxyModel) allows one to decide
0033      * which rows to show. In this specific model we only allow directories to
0034      * be shown.
0035      */
0036     bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const override;
0037 
0038     /**
0039      * Reimplemented method from QSortFilterProxyModel. Prevents from sorting
0040      * top-level elements. Sorting top-level elements is not desirable in MixedView as
0041      * we need fixed order of items there (first audio part, second data part)
0042      */
0043     bool lessThan( const QModelIndex& left, const QModelIndex& right ) const override;
0044 };
0045 }
0046 
0047 #endif