Debian Codegraph @

core/libs/album/treeview/albumlabelssearchhandler.h

raw
1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2014-05-17
7 * Description : Album Labels Search Tree View.
8 *
9 * SPDX-FileCopyrightText: 2014-2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
10 * SPDX-FileCopyrightText: 2014-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 #include "labelstreeview.h"
19
20 namespace Digikam
21 {
22
23 class AlbumLabelsSearchHandler : public QObject
24 {
25 Q_OBJECT
26
27 public:
28
29 explicit AlbumLabelsSearchHandler(LabelsTreeView* const treeWidget);
30 ~AlbumLabelsSearchHandler() override;
31
32 /**
33 * @return Album pointer of the currently selected labels
34 */
35 Album* albumForSelectedItems() const;
36
37 /**
38 * @brief Gets the list of images generated, for exporting
39 *
40 * @return QUrl List of images Urls
41 */
42 QList<QUrl> imagesUrls() const;
43
44 /**
45 * @return A string for a name generated by @see
46 * generateAlbumNameForExporting()
47 */
48 QString generatedName() const;
49
50 /**
51 * @brief Restores the selection of the tree-view from history
52 *
53 * @param neededLabels a hash to restore selection from it
54 */
55 void restoreSelectionFromHistory(const QHash<LabelsTreeView::Labels,
56 QList<int> >& neededLabels);
57
58 /**
59 * @return true if the tree-view is restoring the selection state
60 * from history to block searching until the restoring
61 * is done
62 */
63 bool isRestoringSelectionFromHistory() const;
64
65 private:
66
67 /**
68 * @brief Create XML for currently selected labels
69 *
70 * @param selectedLabels to generate XML for it
71 * @return XML generated
72 */
73 QString createXMLForCurrentSelection(const QHash<LabelsTreeView::Labels,
74 QList<int> >& selectedLabels);
75
76 /**
77 * @brief Passes the generated XML to CoreDB class
78 * search methods
79 *
80 * @param xml generated from @see createXMLForCurrentSelection
81 * @return A pointer of the search album created by the CoreDB
82 */
83 SAlbum* search(const QString& xml) const;
84
85 /**
86 * @brief Generates album name based on the selected labels for
87 * example if rating 2 and 5 are selected then the name is
88 * "Rating: 2, 5", If there are any selected picks for example
89 * Pending, then the generated name is "Rating: 2, 5 | Picks: Pending"
90 */
91 void generateAlbumNameForExporting(const QList<int>& ratings,
92 const QList<int>& colorsList,
93 const QList<int>& picksList);
94
95 /**
96 * @brief Passes the current album DB url to a DBJobsManager
97 * to get images urls in this album
98 */
99 void imagesUrlsForCurrentAlbum();
100
101 /**
102 * @return "Labels Album" if the tree-widget is not checkable
103 * and returns "Exporting Album" if it was checkable
104 */
105 QString getDefaultTitle() const;
106
107 private Q_SLOTS:
108
109 void slotSelectionChanged();
110 void slotCheckStateChanged();
111 void slotSetCurrentAlbum();
112 void slotResult();
113 void slotData(const QList<ItemListerRecord>& data);
114
115 Q_SIGNALS:
116
117 void checkStateChanged(Album* album, Qt::CheckState checkState);
118
119 private:
120
121 class Private;
122 Private* const d = nullptr;
123 };
124
125 } // namespace Digikam