digiKam
Loading...
Searching...
No Matches
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 * SPDX-FileCopyrightText: 2013 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
13 * ============================================================ */
14
15#pragma once
16
17// Qt includes
18
19#include <QObject>
20
21// Local includes
22
24#include "showfotoitemmodel.h"
27
28namespace ShowFoto
29{
30
31class ShowfotoFilterModel;
32
34{
35 Q_OBJECT
36
37public:
38
39 explicit ShowfotoSortFilterModel(QObject* const parent = nullptr);
40 ~ShowfotoSortFilterModel() override;
41
42 void setSourceShowfotoModel(ShowfotoItemModel* const sourceModel);
44
45 void setSourceFilterModel(ShowfotoSortFilterModel* const sourceModel);
47
52 QModelIndex mapToSourceShowfotoModel(const QModelIndex& proxyIndex) const;
53 QModelIndex mapFromSourceShowfotoModel(const QModelIndex& showfotoModelIndex) const;
54 QModelIndex mapFromDirectSourceToSourceShowfotoModel(const QModelIndex& sourceModelIndex) const;
55
56 QList<QModelIndex> mapListToSource(const QList<QModelIndex>& indexes) const;
57 QList<QModelIndex> mapListFromSource(const QList<QModelIndex>& sourceIndexes) const;
58
59 ShowfotoItemInfo showfotoItemInfo(const QModelIndex& index) const;
60 qlonglong showfotoItemId(const QModelIndex& index) const;
61 QList<ShowfotoItemInfo> showfotoItemInfos(const QList<QModelIndex>& indexes) const;
62 QList<qlonglong> showfotoItemIds(const QList<QModelIndex>& indexes) const;
63
64 QModelIndex indexForUrl(const QUrl& fileUrl) const;
65 QModelIndex indexForShowfotoItemInfo(const ShowfotoItemInfo& info) const;
66 QModelIndex indexForShowfotoItemId(qlonglong id) const;
67
72 QList<ShowfotoItemInfo> showfotoItemInfosSorted() const;
73
76
77protected:
78
79 void setSourceModel(QAbstractItemModel* sourceModel) override;
80
82 virtual void setDirectSourceShowfotoModel(ShowfotoItemModel* const sourceModel);
83
84protected:
85
87};
88
89// ------------------------------------------------------------------------------------------
90
92{
93 Q_OBJECT
94
95public:
96
114
115public:
116
117 explicit ShowfotoFilterModel(QObject* const parent = nullptr);
118 ~ShowfotoFilterModel() override;
119
121
123
125 void setSendShowfotoItemInfoSignals(bool sendSignals);
126/*
127 TODO: Implement grouping in Showfoto tool.
128 bool isGroupOpen(qlonglong group) const;
129 bool isAllGroupsOpen() const;
130*/
131 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
133
134public Q_SLOTS:
135
139/*
140 TODO: Implement grouping in Showfoto tool.
141 void setGroupOpen(qlonglong group, bool open);
142 void toggleGroupOpen(qlonglong group);
143 void setAllGroupsOpen(bool open);
144
146 TODO: Implement filtering in Showfoto tool.
147 virtual void setItemFilterSettings(const ItemFilterSettings& settings);
148
150 TODO: virtual void setItemSortSettings(const ItemSortSettings& settings);
151*/
152
153Q_SIGNALS:
154
158 void showfotoItemInfosAdded(const QList<ShowfotoItemInfo>& infos);
159 void showfotoItemInfosAboutToBeRemoved(const QList<ShowfotoItemInfo>& infos);
160
161protected Q_SLOTS:
162
163 void slotRowsInserted(const QModelIndex& parent, int start, int end);
164 void slotRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
165
166public:
167
169 class ShowfotoFilterModelPrivate;
170
171protected:
172
173 ShowfotoFilterModelPrivate* const d_ptr = nullptr;
174
175protected:
176
177 void setDirectSourceShowfotoModel(ShowfotoItemModel* const sourceModel) override;
178/*
179 TODO
180 virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
181*/
182 int compareCategories(const QModelIndex& left, const QModelIndex& right) const override;
183 bool subSortLessThan(const QModelIndex& left, const QModelIndex& right) const override;
184
190 virtual int compareInfosCategories(const ShowfotoItemInfo& left,
191 const ShowfotoItemInfo& right) const;
192
196 virtual bool infosLessThan(const ShowfotoItemInfo& left,
197 const ShowfotoItemInfo& right) const;
198
202 virtual QString categoryIdentifier(const ShowfotoItemInfo& info) const;
203
204private:
205
206 Q_DECLARE_PRIVATE(ShowfotoFilterModel)
207};
208
209// -----------------------------------------------------------------------------------------------------
210
212{
213 Q_OBJECT
214
215public:
216
217 explicit NoDuplicatesShowfotoFilterModel(QObject* const parent = nullptr);
218
219protected:
220
221 bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
222};
223
224} // namespace ShowFoto
225
226Q_DECLARE_METATYPE(ShowFoto::ShowfotoFilterModel*)
Definition dcategorizedsortfilterproxymodel.h:43
Definition showfotofiltermodel.h:212
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition showfotofiltermodel.cpp:508
Definition showfotofiltermodel.h:92
void setSortRole(ShowfotoItemSortSettings::SortRole role)
Definition showfotofiltermodel.cpp:322
virtual QString categoryIdentifier(const ShowfotoItemInfo &info) const
Definition showfotofiltermodel.cpp:473
void showfotoItemInfosAdded(const QList< ShowfotoItemInfo > &infos)
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:382
void slotRowsInserted(const QModelIndex &parent, int start, int end)
Definition showfotofiltermodel.cpp:358
ShowfotoFilterModelRoles
Definition showfotofiltermodel.h:98
@ SortOrderRole
Returns the current sort order.
Definition showfotofiltermodel.h:103
@ ShowfotoFilterModelPointerRole
Definition showfotofiltermodel.h:112
@ CategorizationModeRole
Returns the current categorization mode.
Definition showfotofiltermodel.h:100
@ CategoryFormatRole
Returns the format of the index which is used for category.
Definition showfotofiltermodel.h:106
~ShowfotoFilterModel() override
Definition showfotofiltermodel.cpp:251
virtual bool infosLessThan(const ShowfotoItemInfo &left, const ShowfotoItemInfo &right) const
Definition showfotofiltermodel.cpp:466
void slotRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition showfotofiltermodel.cpp:370
ShowfotoFilterModelPrivate *const d_ptr
Definition showfotofiltermodel.h:173
void setShowfotoItemSortSettings(const ShowfotoItemSortSettings &sorter)
Definition showfotofiltermodel.cpp:305
void setSortOrder(ShowfotoItemSortSettings::SortOrder order)
Definition showfotofiltermodel.cpp:330
bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const override
Definition showfotofiltermodel.cpp:434
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition showfotofiltermodel.cpp:258
void showfotoItemInfosAboutToBeRemoved(const QList< ShowfotoItemInfo > &infos)
virtual int compareInfosCategories(const ShowfotoItemInfo &left, const ShowfotoItemInfo &right) const
Definition showfotofiltermodel.cpp:459
void setCategorizationMode(ShowfotoItemSortSettings::CategorizationMode mode)
Definition showfotofiltermodel.cpp:314
void setSendShowfotoItemInfoSignals(bool sendSignals)
Enables sending ShowfotoItemInfosAdded and ShowfotoItemInfosAboutToBeRemoved.
Definition showfotofiltermodel.cpp:338
ShowfotoFilterModel * showfotoFilterModel() const override
Returns this, any chained ShowfotoFilterModel, or 0.
Definition showfotofiltermodel.cpp:298
int compareCategories(const QModelIndex &left, const QModelIndex &right) const override
Definition showfotofiltermodel.cpp:416
Definition showfotoiteminfo.h:38
Definition showfotoitemmodel.h:37
@ FilterModelRoles
Definition showfotoitemmodel.h:66
Definition showfotoitemsortsettings.h:29
SortOrder
Definition showfotoitemsortsettings.h:33
SortRole
Definition showfotoitemsortsettings.h:47
CategorizationMode
Definition showfotoitemsortsettings.h:40
Definition showfotofiltermodel.h:34
ShowfotoSortFilterModel * m_chainedModel
Definition showfotofiltermodel.h:86
QModelIndex indexForShowfotoItemInfo(const ShowfotoItemInfo &info) const
Definition showfotofiltermodel.cpp:167
QModelIndex indexForShowfotoItemId(qlonglong id) const
Definition showfotofiltermodel.cpp:172
QList< QModelIndex > mapListToSource(const QList< QModelIndex > &indexes) const
Definition showfotofiltermodel.cpp:121
ShowfotoItemInfo showfotoItemInfo(const QModelIndex &index) const
Definition showfotofiltermodel.cpp:145
void setSourceFilterModel(ShowfotoSortFilterModel *const sourceModel)
Definition showfotofiltermodel.cpp:55
QList< ShowfotoItemInfo > showfotoItemInfos(const QList< QModelIndex > &indexes) const
Definition showfotofiltermodel.cpp:150
void setSourceModel(QAbstractItemModel *sourceModel) override
Definition showfotofiltermodel.cpp:200
qlonglong showfotoItemId(const QModelIndex &index) const
void setSourceShowfotoModel(ShowfotoItemModel *const sourceModel)
Definition showfotofiltermodel.cpp:33
ShowfotoSortFilterModel * sourceFilterModel() const
Definition showfotofiltermodel.cpp:71
~ShowfotoSortFilterModel() override
Definition showfotofiltermodel.cpp:29
QList< QModelIndex > mapListFromSource(const QList< QModelIndex > &sourceIndexes) const
Definition showfotofiltermodel.cpp:133
QModelIndex mapToSourceShowfotoModel(const QModelIndex &proxyIndex) const
Definition showfotofiltermodel.cpp:76
QList< ShowfotoItemInfo > showfotoItemInfosSorted() const
Definition showfotofiltermodel.cpp:177
ShowfotoItemModel * sourceShowfotoModel() const
Definition showfotofiltermodel.cpp:45
QModelIndex mapFromDirectSourceToSourceShowfotoModel(const QModelIndex &sourceModelIndex) const
Definition showfotofiltermodel.cpp:106
virtual ShowfotoFilterModel * showfotoFilterModel() const
Returns this, any chained ShowfotoFilterModel, or 0.
Definition showfotofiltermodel.cpp:190
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:205
QModelIndex indexForUrl(const QUrl &fileUrl) const
Definition showfotofiltermodel.cpp:162
QModelIndex mapFromSourceShowfotoModel(const QModelIndex &showfotoModelIndex) const
Definition showfotofiltermodel.cpp:91
Definition showfotofolderviewbar.cpp:43