digiKam
showfotofiltermodel.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 : 30-07-2013
7  * Description : Qt filter model for showfoto items
8  *
9  * Copyright (C) 2013 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef SHOW_FOTO_FILTER_MODEL_H
25 #define SHOW_FOTO_FILTER_MODEL_H
26 
27 // Qt includes
28 
29 #include <QObject>
30 
31 // Local includes
32 
34 #include "showfotoitemmodel.h"
35 #include "showfotothumbnailmodel.h"
37 
38 namespace ShowFoto
39 {
40 
41 class ShowfotoFilterModel;
42 
44 {
45  Q_OBJECT
46 
47 public:
48 
49  explicit ShowfotoSortFilterModel(QObject* const parent = nullptr);
50  ~ShowfotoSortFilterModel() override;
51 
52  void setSourceShowfotoModel(ShowfotoItemModel* const sourceModel);
54 
55  void setSourceFilterModel(ShowfotoSortFilterModel* const sourceModel);
57 
62  QModelIndex mapToSourceShowfotoModel(const QModelIndex& proxyIndex) const;
63  QModelIndex mapFromSourceShowfotoModel(const QModelIndex& showfotoModelIndex) const;
64  QModelIndex mapFromDirectSourceToSourceShowfotoModel(const QModelIndex& sourceModelIndex) const;
65 
67  QList<QModelIndex> mapListFromSource(const QList<QModelIndex>& sourceIndexes) const;
68 
69  ShowfotoItemInfo showfotoItemInfo(const QModelIndex& index) const;
70  qlonglong showfotoItemId(const QModelIndex& index) const;
73 
74  QModelIndex indexForUrl(const QUrl& fileUrl) const;
75  QModelIndex indexForShowfotoItemInfo(const ShowfotoItemInfo& info) const;
76  QModelIndex indexForShowfotoItemId(qlonglong id) const;
77 
83 
86 
87 protected:
88 
89  void setSourceModel(QAbstractItemModel* sourceModel) override;
90 
92  virtual void setDirectSourceShowfotoModel(ShowfotoItemModel* const sourceModel);
93 
94 protected:
95 
97 };
98 
99 // ------------------------------------------------------------------------------------------
100 
102 {
103  Q_OBJECT
104 
105 public:
106 
108  {
111 
114 
117 
123  };
124 
125 public:
126 
127  explicit ShowfotoFilterModel(QObject* const parent = nullptr);
128  ~ShowfotoFilterModel() override;
129 
131 
133 
135  void setSendShowfotoItemInfoSignals(bool sendSignals);
136 /*
137  TODO: Implement grouping in Showfoto tool.
138  bool isGroupOpen(qlonglong group) const;
139  bool isAllGroupsOpen() const;
140 */
141  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
142  ShowfotoFilterModel* showfotoFilterModel() const override;
143 
144 public Q_SLOTS:
145 
149 /*
150  TODO: Implement grouping in Showfoto tool.
151  void setGroupOpen(qlonglong group, bool open);
152  void toggleGroupOpen(qlonglong group);
153  void setAllGroupsOpen(bool open);
154 
156  TODO: Implement filtering in Showfoto tool.
157  virtual void setItemFilterSettings(const ItemFilterSettings& settings);
158 
160  TODO: virtual void setItemSortSettings(const ItemSortSettings& settings);
161 */
162 
163 Q_SIGNALS:
164 
170 
171 protected Q_SLOTS:
172 
173  void slotRowsInserted(const QModelIndex& parent, int start, int end);
174  void slotRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
175 
176 public:
177 
179  class ShowfotoFilterModelPrivate;
180 
181 protected:
182 
183  ShowfotoFilterModelPrivate* const d_ptr;
184 
185 protected:
186 
187  void setDirectSourceShowfotoModel(ShowfotoItemModel* const sourceModel) override;
188 /*
189  TODO
190  virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
191 */
192  int compareCategories(const QModelIndex& left, const QModelIndex& right) const override;
193  bool subSortLessThan(const QModelIndex& left, const QModelIndex& right) const override;
194 
200  virtual int compareInfosCategories(const ShowfotoItemInfo& left,
201  const ShowfotoItemInfo& right) const;
202 
206  virtual bool infosLessThan(const ShowfotoItemInfo& left,
207  const ShowfotoItemInfo& right) const;
208 
212  virtual QString categoryIdentifier(const ShowfotoItemInfo& info) const;
213 
214 private:
215 
216  Q_DECLARE_PRIVATE(ShowfotoFilterModel)
217 };
218 
219 // -----------------------------------------------------------------------------------------------------
220 
222 {
223  Q_OBJECT
224 
225 public:
226 
227  explicit NoDuplicatesShowfotoFilterModel(QObject* const parent = nullptr);
228 
229 protected:
230 
231  bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
232 };
233 
234 } // namespace ShowFoto
235 
236 Q_DECLARE_METATYPE(ShowFoto::ShowfotoFilterModel*)
237 
238 #endif // SHOW_FOTO_FILTER_MODEL_H
Definition: dcategorizedsortfilterproxymodel.h:53
Definition: showfotofiltermodel.h:222
NoDuplicatesShowfotoFilterModel(QObject *const parent=nullptr)
Definition: showfotofiltermodel.cpp:512
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition: showfotofiltermodel.cpp:517
Definition: showfotofiltermodel.h:102
void setSortRole(ShowfotoItemSortSettings::SortRole role)
Definition: showfotofiltermodel.cpp:333
virtual QString categoryIdentifier(const ShowfotoItemInfo &info) const
Definition: showfotofiltermodel.cpp:482
void showfotoItemInfosAdded(const QList< ShowfotoItemInfo > &infos)
ShowfotoFilterModel(QObject *const parent=nullptr)
Definition: showfotofiltermodel.cpp:258
ShowfotoItemSortSettings showfotoItemSortSettings() const
void setDirectSourceShowfotoModel(ShowfotoItemModel *const sourceModel) override
Reimplement if needed. Called only when model shall be set as (direct) sourceModel.
Definition: showfotofiltermodel.cpp:391
void slotRowsInserted(const QModelIndex &parent, int start, int end)
Definition: showfotofiltermodel.cpp:367
ShowfotoFilterModelRoles
Definition: showfotofiltermodel.h:108
@ SortOrderRole
Returns the current sort order.
Definition: showfotofiltermodel.h:113
@ ShowfotoFilterModelPointerRole
Definition: showfotofiltermodel.h:122
@ CategorizationModeRole
Returns the current categorization mode.
Definition: showfotofiltermodel.h:110
@ CategoryFormatRole
Returns the format of the index which is used for category.
Definition: showfotofiltermodel.h:116
~ShowfotoFilterModel() override
Definition: showfotofiltermodel.cpp:265
virtual bool infosLessThan(const ShowfotoItemInfo &left, const ShowfotoItemInfo &right) const
Definition: showfotofiltermodel.cpp:475
void slotRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: showfotofiltermodel.cpp:379
ShowfotoFilterModelPrivate *const d_ptr
Definition: showfotofiltermodel.h:179
void setShowfotoItemSortSettings(const ShowfotoItemSortSettings &sorter)
Definition: showfotofiltermodel.cpp:318
void setSortOrder(ShowfotoItemSortSettings::SortOrder order)
Definition: showfotofiltermodel.cpp:340
bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const override
Definition: showfotofiltermodel.cpp:443
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: showfotofiltermodel.cpp:271
void showfotoItemInfosAboutToBeRemoved(const QList< ShowfotoItemInfo > &infos)
virtual int compareInfosCategories(const ShowfotoItemInfo &left, const ShowfotoItemInfo &right) const
Definition: showfotofiltermodel.cpp:468
void setCategorizationMode(ShowfotoItemSortSettings::CategorizationMode mode)
Definition: showfotofiltermodel.cpp:326
void setSendShowfotoItemInfoSignals(bool sendSignals)
Enables sending ShowfotoItemInfosAdded and ShowfotoItemInfosAboutToBeRemoved.
Definition: showfotofiltermodel.cpp:347
ShowfotoFilterModel * showfotoFilterModel() const override
Returns this, any chained ShowfotoFilterModel, or 0.
Definition: showfotofiltermodel.cpp:311
int compareCategories(const QModelIndex &left, const QModelIndex &right) const override
Definition: showfotofiltermodel.cpp:425
Definition: showfotoiteminfo.h:48
Definition: showfotoitemmodel.h:47
@ FilterModelRoles
Definition: showfotoitemmodel.h:76
Definition: showfotoitemsortsettings.h:39
SortOrder
Definition: showfotoitemsortsettings.h:43
SortRole
Definition: showfotoitemsortsettings.h:57
CategorizationMode
Definition: showfotoitemsortsettings.h:50
Definition: showfotofiltermodel.h:44
ShowfotoSortFilterModel * m_chainedModel
Definition: showfotofiltermodel.h:96
QModelIndex indexForShowfotoItemInfo(const ShowfotoItemInfo &info) const
Definition: showfotofiltermodel.cpp:177
QModelIndex indexForShowfotoItemId(qlonglong id) const
Definition: showfotofiltermodel.cpp:182
QList< QModelIndex > mapListToSource(const QList< QModelIndex > &indexes) const
Definition: showfotofiltermodel.cpp:131
ShowfotoItemInfo showfotoItemInfo(const QModelIndex &index) const
Definition: showfotofiltermodel.cpp:155
void setSourceFilterModel(ShowfotoSortFilterModel *const sourceModel)
Definition: showfotofiltermodel.cpp:65
QList< ShowfotoItemInfo > showfotoItemInfos(const QList< QModelIndex > &indexes) const
Definition: showfotofiltermodel.cpp:160
void setSourceModel(QAbstractItemModel *sourceModel) override
Definition: showfotofiltermodel.cpp:210
qlonglong showfotoItemId(const QModelIndex &index) const
void setSourceShowfotoModel(ShowfotoItemModel *const sourceModel)
Definition: showfotofiltermodel.cpp:43
ShowfotoSortFilterModel * sourceFilterModel() const
Definition: showfotofiltermodel.cpp:81
ShowfotoSortFilterModel(QObject *const parent=nullptr)
Definition: showfotofiltermodel.cpp:33
~ShowfotoSortFilterModel() override
Definition: showfotofiltermodel.cpp:39
QList< QModelIndex > mapListFromSource(const QList< QModelIndex > &sourceIndexes) const
Definition: showfotofiltermodel.cpp:143
QModelIndex mapToSourceShowfotoModel(const QModelIndex &proxyIndex) const
Definition: showfotofiltermodel.cpp:86
QList< ShowfotoItemInfo > showfotoItemInfosSorted() const
Definition: showfotofiltermodel.cpp:187
ShowfotoItemModel * sourceShowfotoModel() const
Definition: showfotofiltermodel.cpp:55
QModelIndex mapFromDirectSourceToSourceShowfotoModel(const QModelIndex &sourceModelIndex) const
Definition: showfotofiltermodel.cpp:116
virtual ShowfotoFilterModel * showfotoFilterModel() const
Returns this, any chained ShowfotoFilterModel, or 0.
Definition: showfotofiltermodel.cpp:200
QList< qlonglong > showfotoItemIds(const QList< QModelIndex > &indexes) const
virtual void setDirectSourceShowfotoModel(ShowfotoItemModel *const sourceModel)
Reimplement if needed. Called only when model shall be set as (direct) sourceModel.
Definition: showfotofiltermodel.cpp:215
QModelIndex indexForUrl(const QUrl &fileUrl) const
Definition: showfotofiltermodel.cpp:172
QModelIndex mapFromSourceShowfotoModel(const QModelIndex &showfotoModelIndex) const
Definition: showfotofiltermodel.cpp:101
Definition: showfotofolderviewbar.cpp:52