digiKam
albummodel.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 : 2008-03-22
7  * Description : Qt Model for Albums
8  *
9  * Copyright (C) 2008-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
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 DIGIKAM_ALBUM_MODEL_H
25 #define DIGIKAM_ALBUM_MODEL_H
26 
27 // Qt includes
28 
29 #include <QDateTime>
30 
31 // Local includes
32 
33 #include "abstractalbummodel.h"
34 #include "digikam_export.h"
35 
36 namespace Digikam
37 {
38 
39 class DIGIKAM_GUI_EXPORT AlbumModel : public AbstractCheckableAlbumModel
40 {
41  Q_OBJECT
42 
43 public:
44 
48  explicit AlbumModel(RootAlbumBehavior rootBehavior = IncludeRootAlbum, QObject* const parent = nullptr);
49  ~AlbumModel() override;
50 
51  PAlbum* albumForIndex(const QModelIndex& index) const;
52 
53 protected:
54 
55  QVariant albumData(Album* a, int role) const override;
56  QVariant decorationRoleData(Album* a) const override;
57  Album* albumForId(int id) const override;
58 };
59 
60 // ------------------------------------------------------------------
61 
62 class DIGIKAM_GUI_EXPORT TagModel : public AbstractCheckableAlbumModel
63 {
64  Q_OBJECT
65 
66 public:
67 
71  explicit TagModel(RootAlbumBehavior rootBehavior = IncludeRootAlbum, QObject* const parent = nullptr);
72 
73  TAlbum* albumForIndex(const QModelIndex& index) const;
74  void setColumnHeader(const QString& header);
75  void activateFaceTagModel();
76 
77 protected:
78 
79  QVariant albumData(Album* a, int role) const override;
80  QVariant decorationRoleData(Album* a) const override;
81  Album* albumForId(int id) const override;
82  QVariant fontRoleData(Album* a) const override;
83  bool setData(const QModelIndex& index,
84  const QVariant& value,
85  int role = Qt::EditRole) override;
86 
87 private:
88 
89  QMap<int, int> m_unconfirmedFaceCount;
90 };
91 
92 // ------------------------------------------------------------------
93 
94 class DIGIKAM_GUI_EXPORT SearchModel : public AbstractCheckableAlbumModel
95 {
96  Q_OBJECT
97 
98 public:
99 
103  explicit SearchModel(QObject* const parent = nullptr);
104 
105  SAlbum* albumForIndex(const QModelIndex& index) const;
106 
111  void setReplaceNames(const QHash<QString, QString>& replaceNames);
112  void addReplaceName(const QString& technicalName, const QString& userVisibleName);
113 
117  void setPixmapForNormalSearches(const QPixmap& pix);
118  void setDefaultPixmap(const QPixmap& pix);
119  void setPixmapForTimelineSearches(const QPixmap& pix);
120  void setPixmapForHaarSearches(const QPixmap& pix);
121  void setPixmapForMapSearches(const QPixmap& pix);
122  void setPixmapForDuplicatesSearches(const QPixmap& pix);
123 
124 protected:
125 
126  QVariant albumData(Album* a, int role) const override;
127  Album* albumForId(int id) const override;
128 
129 private Q_SLOTS:
130 
131  void albumSettingsChanged();
132 
133 protected:
134 
135  QHash<int, QPixmap> m_pixmaps;
136  QHash<QString, QString> m_replaceNames;
137 };
138 
139 // ------------------------------------------------------------------
140 
144 class DIGIKAM_GUI_EXPORT DateAlbumModel : public AbstractCountingAlbumModel
145 {
146  Q_OBJECT
147 
148 public:
149 
155  explicit DateAlbumModel(QObject* const parent = nullptr);
156 
157  DAlbum* albumForIndex(const QModelIndex& index) const;
158 
168  QModelIndex monthIndexForDate(const QDate& date) const;
169 
173  void setPixmaps(const QPixmap& forYearAlbums,
174  const QPixmap& forMonthAlbums);
175 
176 public Q_SLOTS:
177 
178  void setYearMonthMap(const QMap<YearMonth, int>& yearMonthMap);
179 
180 protected:
181 
182  QString albumName(Album* a) const override;
183  QVariant decorationRoleData(Album* a) const override;
184  QVariant sortRoleData(Album* a) const override;
185  Album* albumForId(int id) const override;
186 
187 protected:
188 
189  QPixmap m_yearPixmap;
190  QPixmap m_monthPixmap;
191 };
192 
193 } // namespace Digikam
194 
195 #endif // DIGIKAM_ALBUM_MODEL_H
RootAlbumBehavior
Definition: abstractalbummodel.h:60
Definition: abstractalbummodel.h:358
Definition: abstractalbummodel.h:271
Definition: albummodel.h:40
Abstract base class for all album types.
Definition: album.h:67
Definition: album.h:460
Definition: albummodel.h:145
QPixmap m_yearPixmap
Definition: albummodel.h:189
QPixmap m_monthPixmap
Definition: albummodel.h:190
Definition: album.h:357
Definition: album.h:493
Definition: albummodel.h:95
QHash< int, QPixmap > m_pixmaps
Definition: albummodel.h:135
QHash< QString, QString > m_replaceNames
Definition: albummodel.h:136
Definition: album.h:420
Definition: albummodel.h:63
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43