Debian Codegraph @

core/libs/album/widgets/albumselectors.h

raw
1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2010-10-09
7 * Description : A widget to select Physical or virtual albums with combo-box
8 *
9 * SPDX-FileCopyrightText: 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10 * SPDX-FileCopyrightText: 2012-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 *
14 * ============================================================ */
15
16 #pragma once
17
18 // Qt includes
19
20 #include <QWidget>
21
22 namespace Digikam
23 {
24
25 class Album;
26 typedef QList<Album*> AlbumList;
27
28 class AlbumSelectors : public QWidget
29 {
30 Q_OBJECT
31
32 public:
33
34 enum AlbumType
35 {
36 PhysAlbum = 0,
37 TagsAlbum,
38 All
39 };
40
41 enum SelectionType
42 {
43 SingleSelection = 0,
44 MultipleSelection
45 };
46
47 public:
48
49 /**
50 * Default Constructor. 'label' is front text of label which title widget. 'configName' is name used to store
51 * Albums configuration in settings file. 'parent' is parent widget.
52 */
53 explicit AlbumSelectors(const QString& label,
54 const QString& configName,
55 QWidget* const parent = nullptr,
56 AlbumType albumType = All,
57 bool allowRecursive = false);
58 ~AlbumSelectors() override;
59
60 /**
61 * Return list of selected physical albums
62 */
63 AlbumList selectedAlbums() const;
64
65 /**
66 * Return list of selected physical album ids
67 */
68 QList<int> selectedAlbumIds() const;
69
70 /**
71 * Return list of selected tag albums
72 */
73 AlbumList selectedTags() const;
74
75 /**
76 * Return list of selected tag album ids
77 */
78 QList<int> selectedTagIds() const;
79
80 /**
81 * Return list of selected physical and tag albums.
82 */
83 AlbumList selectedAlbumsAndTags() const;
84
85 /**
86 * Reset all Physical Albums selection.
87 */
88 void resetPAlbumSelection();
89
90 /**
91 * Reset all Tag Albums selection.
92 */
93 void resetTAlbumSelection();
94
95 /**
96 * Reset all Physical and Tag Albums selection.
97 */
98 void resetSelection();
99
100 /** Select Physical Album from list. If singleSelection is true, only this one is
101 * selected from tree-view and all others are deselected.
102 */
103 void setAlbumSelected(Album* const album, SelectionType type);
104
105 /** Select Tag Album from list. If singleSelection is true, only this one is
106 * selected from tree-view and all others are deselected.
107 */
108 void setTagSelected(Album* const album, SelectionType type);
109
110 /**
111 * Sets the search type selection with the AlbumType.
112 */
113 void setTypeSelection(int albumType);
114
115 /**
116 * Returns the selected album type.
117 */
118 int typeSelection() const;
119
120 /**
121 * Return true if whole Albums collection option is checked.
122 */
123 bool wholeAlbumsChecked() const;
124
125 /**
126 * Return true if whole Tags collection option is checked.
127 */
128 bool wholeTagsChecked() const;
129
130 public Q_SLOTS:
131
132 /**
133 * Called in constructor. Restore previous settings saved in configuration file.
134 */
135 void loadState();
136
137 /**
138 * Save settings in configuration file. Must be called explicitly by host implementation.
139 */
140 void saveState();
141
142 Q_SIGNALS:
143
144 void signalSelectionChanged();
145
146 private Q_SLOTS:
147
148 void slotUpdateClearButtons();
149 void slotWholeAlbums(bool);
150 void slotWholeTags(bool);
151
152 private:
153
154 void initAlbumWidget();
155 void initTagWidget();
156 void updateTabText();
157
158 private:
159
160 class Private;
161 Private* const d = nullptr;
162 };
163
164 } // namespace Digikam