File indexing completed on 2024-05-05 16:27:55
0001 // SPDX-FileCopyrightText: 2009 Jan Kundrát <jkt@flaska.net> 0002 // SPDX-FileCopyrightText: 2009-2013 Jesper K. Pedersen <jesper.pedersen@kdab.com> 0003 // SPDX-FileCopyrightText: 2013-2023 Johannes Zarl-Zierl <johannes@zarl-zierl.at> 0004 // 0005 // SPDX-License-Identifier: GPL-2.0-or-later 0006 0007 #ifndef ABSTRACTCATEGORYMODEL_H 0008 #define ABSTRACTCATEGORYMODEL_H 0009 #include <DB/Category.h> 0010 #include <DB/CategoryPtr.h> 0011 #include <DB/search/ImageSearchInfo.h> 0012 0013 #include <QAbstractItemModel> 0014 0015 namespace Browser 0016 { 0017 0018 /** 0019 * \brief Base class for Category models 0020 * 0021 * See \ref Browser for a detailed description of how this fits in with the rest of the classes in this module 0022 * 0023 * This class implements what is common for \ref FlatCategoryModel and \ref TreeCategoryModel. 0024 */ 0025 class AbstractCategoryModel : public QAbstractItemModel 0026 { 0027 public: 0028 Qt::ItemFlags flags(const QModelIndex &index) const override; 0029 QVariant data(const QModelIndex &index, int role) const override; 0030 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0031 0032 protected: 0033 AbstractCategoryModel(const DB::CategoryPtr &category, const DB::ImageSearchInfo &info); 0034 0035 bool hasNoneEntry() const; 0036 QString text(const QString &name) const; 0037 QPixmap icon(const QString &name) const; 0038 virtual QString indexToName(const QModelIndex &) const = 0; 0039 0040 DB::CategoryPtr m_category; 0041 DB::ImageSearchInfo m_info; 0042 QMap<QString, DB::CountWithRange> m_images; 0043 QMap<QString, DB::CountWithRange> m_videos; 0044 }; 0045 0046 } 0047 0048 #endif /* ABSTRACTCATEGORYMODEL_H */ 0049 0050 // vi:expandtab:tabstop=4 shiftwidth=4: