File indexing completed on 2024-05-19 04:56:00
0001 /** 0002 * \file dirproxymodel.h 0003 * Proxy for filesystem model which filters directories. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 19-Mar-2011 0008 * 0009 * Copyright (C) 2011-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QSortFilterProxyModel> 0030 0031 /** 0032 * Proxy for filesystem model which filters directories. 0033 */ 0034 class DirProxyModel : public QSortFilterProxyModel { 0035 public: 0036 /** 0037 * Constructor. 0038 * 0039 * @param parent parent object 0040 */ 0041 explicit DirProxyModel(QObject* parent = nullptr); 0042 0043 /** 0044 * Get item flags. 0045 * @param index index of item 0046 * @return default flags without editable. 0047 */ 0048 Qt::ItemFlags flags(const QModelIndex& index) const override; 0049 0050 protected: 0051 /** 0052 * Check if row should be included in model. 0053 * 0054 * @param srcRow source row 0055 * @param srcParent source parent 0056 * 0057 * @return true to include row. 0058 */ 0059 bool filterAcceptsRow(int srcRow, const QModelIndex& srcParent) const override; 0060 0061 /** 0062 * Sort comparison function. 0063 * @param left index of left item in source model 0064 * @param right index of right item in source model 0065 * @return true if left is less than right. 0066 */ 0067 bool lessThan(const QModelIndex& left, const QModelIndex& right) const override; 0068 };