File indexing completed on 2025-01-19 03:52:57

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-05-22
0007  * Description : Flickr file list view and items.
0008  *
0009  * SPDX-FileCopyrightText: 2009      by Pieter Edelman <pieter dot edelman at gmx dot net>
0010  * SPDX-FileCopyrightText: 2008-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_FLICKR_LIST_H
0017 #define DIGIKAM_FLICKR_LIST_H
0018 
0019 // Qt includes
0020 
0021 #include <QUrl>
0022 #include <QList>
0023 #include <QLineEdit>
0024 
0025 // Local includes
0026 
0027 #include "ditemslist.h"
0028 
0029 using namespace Digikam;
0030 
0031 namespace DigikamGenericFlickrPlugin
0032 {
0033 
0034 class FlickrList : public DItemsList
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039 
0040     /**
0041      * The different columns in a Flickr list.
0042      */
0043     enum FieldType
0044     {
0045         SAFETYLEVEL = DItemsListView::User1,
0046         CONTENTTYPE = DItemsListView::User2,
0047         TAGS        = DItemsListView::User3,
0048         PUBLIC      = DItemsListView::User4,
0049         FAMILY      = DItemsListView::User5,
0050         FRIENDS     = DItemsListView::User6
0051     };
0052 
0053     /**
0054      * The different possible safety levels recognized by Flickr.
0055      */
0056     enum SafetyLevel
0057     {
0058         SAFE        = 1,
0059         MODERATE    = 2,
0060         RESTRICTED  = 3,
0061         MIXEDLEVELS = -1
0062     };
0063 
0064     /**
0065      * The different possible content types recognized by Flickr.
0066      */
0067     enum ContentType
0068     {
0069         PHOTO      = 1,
0070         SCREENSHOT = 2,
0071         OTHER      = 3,
0072         MIXEDTYPES = -1
0073     };
0074 
0075 public:
0076 
0077     explicit FlickrList(QWidget* const parent = nullptr);
0078     ~FlickrList()                               override;
0079 
0080     void setPublic(Qt::CheckState);
0081     void setFamily(Qt::CheckState);
0082     void setFriends(Qt::CheckState);
0083     void setSafetyLevels(SafetyLevel);
0084     void setContentTypes(ContentType);
0085 
0086 Q_SIGNALS:
0087 
0088     /**
0089      * Signal for notifying when the states of one of the permission columns has
0090      * changed. The first argument specifies which permission has changed, the
0091      * second the state.
0092      */
0093     void signalPermissionChanged(FlickrList::FieldType, Qt::CheckState);
0094 
0095     void signalSafetyLevelChanged(FlickrList::SafetyLevel);
0096     void signalContentTypeChanged(FlickrList::ContentType);
0097 
0098 public Q_SLOTS:
0099 
0100     void slotAddImages(const QList<QUrl>& list) override;
0101 
0102 private:
0103 
0104     void setPermissionState(FieldType, Qt::CheckState);
0105     void singlePermissionChanged(QTreeWidgetItem*, int);
0106     void singleComboBoxChanged(QTreeWidgetItem*, int);
0107 
0108 
0109 private Q_SLOTS:
0110 
0111     void slotItemChanged(QTreeWidgetItem*, int);
0112     void slotItemClicked(QTreeWidgetItem*, int);
0113 
0114 private:
0115 
0116     class Private;
0117     Private* const d;
0118 };
0119 
0120 // -------------------------------------------------------------------------
0121 
0122 class FlickrListViewItem : public DItemsListViewItem
0123 {
0124 
0125 public:
0126 
0127     explicit FlickrListViewItem(DItemsListView* const view,
0128                                 const QUrl& url,
0129                                 bool, bool, bool,
0130                                 FlickrList::SafetyLevel,
0131                                 FlickrList::ContentType);
0132     ~FlickrListViewItem()                       override;
0133 
0134     void setPublic(bool);
0135     void setFamily(bool);
0136     void setFriends(bool);
0137     void setSafetyLevel(FlickrList::SafetyLevel);
0138     void setContentType(FlickrList::ContentType);
0139     bool isPublic()                       const;
0140     bool isFamily()                       const;
0141     bool isFriends()                      const;
0142     FlickrList::SafetyLevel safetyLevel() const;
0143     FlickrList::ContentType contentType() const;
0144 
0145     /**
0146      * Returns the list of extra tags that the user specified for this image.
0147      */
0148     QStringList extraTags()               const;
0149 
0150     /**
0151      * This method should be called when one of the checkboxes is clicked.
0152      */
0153     void toggled();
0154 
0155     void updateItemWidgets()                    override;
0156 
0157 private:
0158 
0159     class Private;
0160     Private* const d;
0161 };
0162 
0163 } // namespace DigikamGenericFlickrPlugin
0164 
0165 #endif // DIGIKAM_FLICKR_LIST_H