File indexing completed on 2025-01-19 03:53:23
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-10-09 0007 * Description : A widget to select Physical or virtual albums with combo-box 0008 * 0009 * SPDX-FileCopyrightText: 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_ALBUM_SELECTORS_H 0017 #define DIGIKAM_ALBUM_SELECTORS_H 0018 0019 // Qt includes 0020 0021 #include <QWidget> 0022 0023 namespace Digikam 0024 { 0025 0026 class Album; 0027 typedef QList<Album*> AlbumList; 0028 0029 class AlbumSelectors : public QWidget 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 0035 enum AlbumType 0036 { 0037 PhysAlbum = 0, 0038 TagsAlbum, 0039 All 0040 }; 0041 0042 enum SelectionType 0043 { 0044 SingleSelection = 0, 0045 MultipleSelection 0046 }; 0047 0048 public: 0049 0050 /** 0051 * Default Constructor. 'label' is front text of label which title widget. 'configName' is name used to store 0052 * Albums configuration in settings file. 'parent' is parent widget. 0053 */ 0054 explicit AlbumSelectors(const QString& label, 0055 const QString& configName, 0056 QWidget* const parent = nullptr, 0057 AlbumType albumType = All, 0058 bool allowRecursive = false); 0059 ~AlbumSelectors() override; 0060 0061 /** 0062 * Return list of selected physical albums 0063 */ 0064 AlbumList selectedAlbums() const; 0065 0066 /** 0067 * Return list of selected physical album ids 0068 */ 0069 QList<int> selectedAlbumIds() const; 0070 0071 /** 0072 * Return list of selected tag albums 0073 */ 0074 AlbumList selectedTags() const; 0075 0076 /** 0077 * Return list of selected tag album ids 0078 */ 0079 QList<int> selectedTagIds() const; 0080 0081 /** 0082 * Return list of selected physical and tag albums. 0083 */ 0084 AlbumList selectedAlbumsAndTags() const; 0085 0086 /** 0087 * Reset all Physical Albums selection. 0088 */ 0089 void resetPAlbumSelection(); 0090 0091 /** 0092 * Reset all Tag Albums selection. 0093 */ 0094 void resetTAlbumSelection(); 0095 0096 /** 0097 * Reset all Physical and Tag Albums selection. 0098 */ 0099 void resetSelection(); 0100 0101 /** Select Physical Album from list. If singleSelection is true, only this one is 0102 * selected from tree-view and all others are deselected. 0103 */ 0104 void setAlbumSelected(Album* const album, SelectionType type); 0105 0106 /** Select Tag Album from list. If singleSelection is true, only this one is 0107 * selected from tree-view and all others are deselected. 0108 */ 0109 void setTagSelected(Album* const album, SelectionType type); 0110 0111 /** 0112 * Sets the search type selection with the AlbumType. 0113 */ 0114 void setTypeSelection(int albumType); 0115 0116 /** 0117 * Returns the selected album type. 0118 */ 0119 int typeSelection() const; 0120 0121 /** 0122 * Return true if whole Albums collection option is checked. 0123 */ 0124 bool wholeAlbumsChecked() const; 0125 0126 /** 0127 * Return true if whole Tags collection option is checked. 0128 */ 0129 bool wholeTagsChecked() const; 0130 0131 public Q_SLOTS: 0132 0133 /** 0134 * Called in constructor. Restore previous settings saved in configuration file. 0135 */ 0136 void loadState(); 0137 0138 /** 0139 * Save settings in configuration file. Must be called explicitly by host implementation. 0140 */ 0141 void saveState(); 0142 0143 Q_SIGNALS: 0144 0145 void signalSelectionChanged(); 0146 0147 private Q_SLOTS: 0148 0149 void slotUpdateClearButtons(); 0150 void slotWholeAlbums(bool); 0151 void slotWholeTags(bool); 0152 0153 private: 0154 0155 void initAlbumWidget(); 0156 void initTagWidget(); 0157 void updateTabText(); 0158 0159 private: 0160 0161 class Private; 0162 Private* const d; 0163 }; 0164 0165 } // namespace Digikam 0166 0167 #endif // DIGIKAM_ALBUM_SELECTORS_H