digiKam
dcategorizedsortfilterproxymodel.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2010-01-16
7  * Description : categorize item view based on DCategorizedView
8  *
9  * Copyright (C) 2007 by Rafael Fernández López <ereslibre at kde dot org>
10  * Copyright (C) 2007 by John Tapsell <tapsell at kde dot org>
11  * Copyright (C) 2009-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12  * Copyright (C) 2011-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
13  *
14  * This program is free software; you can redistribute it
15  * and/or modify it under the terms of the GNU General
16  * Public License as published by the Free Software Foundation;
17  * either version 2, or (at your option)
18  * any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * ============================================================ */
26 
27 #ifndef DIGIKAM_DCATEGORIZED_SORT_FILTER_PROXY_MODEL_H
28 #define DIGIKAM_DCATEGORIZED_SORT_FILTER_PROXY_MODEL_H
29 
30 // Qt includes
31 
32 #include <QSortFilterProxyModel>
33 
34 // Local includes
35 
36 #include "digikam_export.h"
37 
38 class QItemSelection;
39 
40 namespace Digikam
41 {
42 
52 class DIGIKAM_EXPORT DCategorizedSortFilterProxyModel : public QSortFilterProxyModel
53 {
54  Q_OBJECT
55 
56 public:
57 
59  {
68  CategoryDisplayRole = 0x17CE990A,
69 
78  CategorySortRole = 0x27857E60
79  };
80 
81  explicit DCategorizedSortFilterProxyModel(QObject* const parent = nullptr);
83 
88  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
89 
93  bool isCategorizedModel() const;
94 
100  void setCategorizedModel(bool categorizedModel);
101 
105  int sortColumn() const;
106 
110  Qt::SortOrder sortOrder() const;
111 
119  void setSortCategoriesByNaturalComparison(bool sortCategoriesByNaturalComparison);
120 
124  bool sortCategoriesByNaturalComparison() const;
125 
126 protected:
140  bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
141 
148  virtual bool subSortLessThan(const QModelIndex& left, const QModelIndex& right) const;
149 
185  virtual int compareCategories(const QModelIndex& left, const QModelIndex& right) const;
186 
187 private:
188 
189  class Private;
190  Private* const d;
191 };
192 
193 // -----------------------------------------------------------------------------------------------------------------------
194 
196 {
197  Q_OBJECT
198 
199 public:
200 
201  explicit ActionSortFilterProxyModel(QObject* const parent = nullptr);
202 
203 protected:
204 
205  bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
206 };
207 
208 } // namespace Digikam
209 
210 #endif // DIGIKAM_DCATEGORIZED_SORT_FILTER_PROXY_MODEL_H
Definition: dcategorizedsortfilterproxymodel.h:196
Definition: dcategorizedsortfilterproxymodel.h:53
AdditionalRoles
Definition: dcategorizedsortfilterproxymodel.h:59
Definition: datefolderview.cpp:43