File indexing completed on 2024-05-05 04:47:27
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef BROWSERCATEGORYLISTMODEL_H 0018 #define BROWSERCATEGORYLISTMODEL_H 0019 0020 #include <QAbstractListModel> 0021 0022 #include <QList> 0023 0024 class BrowserCategory; 0025 Q_DECLARE_METATYPE( BrowserCategory * ) 0026 0027 namespace CustomCategoryRoles 0028 { 0029 enum CustomCategoryRolesId { 0030 CategoryRole = Qt::UserRole + 31, 0031 }; 0032 } 0033 0034 /** 0035 A very simple model to hold the available categories 0036 0037 @author Nikolaj Hald Nielsen <nhn@kde.org> 0038 */ 0039 class BrowserCategoryListModel : public QAbstractListModel 0040 { 0041 public: 0042 explicit BrowserCategoryListModel( QObject *parent = nullptr ); 0043 ~BrowserCategoryListModel() override; 0044 0045 int rowCount( const QModelIndex & parent = QModelIndex() ) const override; 0046 QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override; 0047 0048 /** 0049 * Adds a new sub-category to this list. 0050 * This object will take ownership of the new category. 0051 */ 0052 void addCategory( BrowserCategory* category ); 0053 void removeCategory( BrowserCategory* category ); 0054 0055 private: 0056 QList<BrowserCategory*> m_categories; 0057 }; 0058 0059 #endif