1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2009-05-22
7  * Description : Flickr file list view and items.
8  *
9  * Copyright (C) 2009      by Pieter Edelman <pieter dot edelman at gmx dot net>
10  * Copyright (C) 2008-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option) 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_FLICKR_LIST_H
25 #define DIGIKAM_FLICKR_LIST_H
26 
27 // Qt includes
28 
29 #include <QUrl>
30 #include <QList>
31 #include <QLineEdit>
32 
33 // Local includes
34 
35 #include "ditemslist.h"
36 
37 using namespace Digikam;
38 
39 namespace DigikamGenericFlickrPlugin
40 {
41 
42 class FlickrList : public DItemsList
43 {
44     Q_OBJECT
45 
46 public:
47 
48     /**
49      * The different columns in a Flickr list.
50      */
51     enum FieldType
52     {
53         SAFETYLEVEL = DItemsListView::User1,
54         CONTENTTYPE = DItemsListView::User2,
55         TAGS        = DItemsListView::User3,
56         PUBLIC      = DItemsListView::User4,
57         FAMILY      = DItemsListView::User5,
58         FRIENDS     = DItemsListView::User6
59     };
60 
61     /**
62      * The different possible safety levels recognized by Flickr.
63      */
64     enum SafetyLevel
65     {
66         SAFE        = 1,
67         MODERATE    = 2,
68         RESTRICTED  = 3,
69         MIXEDLEVELS = -1
70     };
71 
72     /**
73      * The different possible content types recognized by Flickr.
74      */
75     enum ContentType
76     {
77         PHOTO      = 1,
78         SCREENSHOT = 2,
79         OTHER      = 3,
80         MIXEDTYPES = -1
81     };
82 
83 public:
84 
85     explicit FlickrList(QWidget* const parent = nullptr);
86     ~FlickrList()                               override;
87 
88     void setPublic(Qt::CheckState);
89     void setFamily(Qt::CheckState);
90     void setFriends(Qt::CheckState);
91     void setSafetyLevels(SafetyLevel);
92     void setContentTypes(ContentType);
93 
94 Q_SIGNALS:
95 
96     /**
97      * Signal for notifying when the states of one of the permission columns has
98      * changed. The first argument specifies which permission has changed, the
99      * second the state.
100      */
101     void signalPermissionChanged(FlickrList::FieldType, Qt::CheckState);
102 
103     void signalSafetyLevelChanged(FlickrList::SafetyLevel);
104     void signalContentTypeChanged(FlickrList::ContentType);
105 
106 public Q_SLOTS:
107 
108     void slotAddImages(const QList<QUrl>& list) override;
109 
110 private:
111 
112     void setPermissionState(FieldType, Qt::CheckState);
113     void singlePermissionChanged(QTreeWidgetItem*, int);
114     void singleComboBoxChanged(QTreeWidgetItem*, int);
115 
116 
117 private Q_SLOTS:
118 
119     void slotItemChanged(QTreeWidgetItem*, int);
120     void slotItemClicked(QTreeWidgetItem*, int);
121 
122 private:
123 
124     class Private;
125     Private* const d;
126 };
127 
128 // -------------------------------------------------------------------------
129 
130 class FlickrListViewItem : public DItemsListViewItem
131 {
132 
133 public:
134 
135     explicit FlickrListViewItem(DItemsListView* const view,
136                                 const QUrl& url,
137                                 bool, bool, bool,
138                                 FlickrList::SafetyLevel,
139                                 FlickrList::ContentType);
140     ~FlickrListViewItem()                       override;
141 
142     void setPublic(bool);
143     void setFamily(bool);
144     void setFriends(bool);
145     void setSafetyLevel(FlickrList::SafetyLevel);
146     void setContentType(FlickrList::ContentType);
147     bool isPublic()                       const;
148     bool isFamily()                       const;
149     bool isFriends()                      const;
150     FlickrList::SafetyLevel safetyLevel() const;
151     FlickrList::ContentType contentType() const;
152 
153     /**
154      * Returns the list of extra tags that the user specified for this image.
155      */
156     QStringList extraTags()               const;
157 
158     /**
159      * This method should be called when one of the checkboxes is clicked.
160      */
161     void toggled();
162 
163     void updateItemWidgets()                    override;
164 
165 private:
166 
167     class Private;
168     Private* const d;
169 };
170 
171 } // namespace DigikamGenericFlickrPlugin
172 
173 #endif // DIGIKAM_FLICKR_LIST_H
174