File indexing completed on 2022-09-27 13:43:07

0001 /* ============================================================
0002  *
0003  * This file is a part of KDE project
0004  *
0005  *
0006  * Date        : 2009-05-22
0007  * Description : Flickr/23HQ file list view and items.
0008  *
0009  * Copyright (C) 2009 by Pieter Edelman <pieter dot edelman at gmx dot net>
0010  *
0011  * This program is free software; you can redistribute it
0012  * and/or modify it under the terms of the GNU General
0013  * Public License as published by the Free Software Foundation;
0014  * either version 2, or (at your option) any later version.
0015  *
0016  * This program is distributed in the hope that it will be useful,
0017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0019  * GNU General Public License for more details.
0020  *
0021  * ============================================================ */
0022 
0023 #ifndef FLICKRLIST_H
0024 #define FLICKRLIST_H
0025 
0026 // Qt includes
0027 
0028 #include <QUrl>
0029 #include <QList>
0030 #include <QLineEdit>
0031 
0032 // Local includes
0033 
0034 #include "kpimageslist.h"
0035 
0036 using namespace KIPIPlugins;
0037 
0038 namespace KIPIFlickrPlugin
0039 {
0040 
0041 class FlickrList : public KPImagesList
0042 {
0043     Q_OBJECT
0044 
0045 public:
0046 
0047     /** The different columns in a Flickr list.
0048      */
0049     enum FieldType
0050     {
0051         SAFETYLEVEL = KPImagesListView::User1,
0052         CONTENTTYPE = KPImagesListView::User2,
0053         TAGS        = KPImagesListView::User3,
0054         PUBLIC      = KPImagesListView::User4,
0055         FAMILY      = KPImagesListView::User5,
0056         FRIENDS     = KPImagesListView::User6
0057     };
0058 
0059     /** The different possible safety levels recognized by Flickr.
0060      */
0061     enum SafetyLevel
0062     {
0063         SAFE        = 1,
0064         MODERATE    = 2,
0065         RESTRICTED  = 3,
0066         MIXEDLEVELS = -1
0067     };
0068 
0069     /** The different possible content types recognized by Flickr.
0070      */
0071     enum ContentType
0072     {
0073         PHOTO      = 1,
0074         SCREENSHOT = 2,
0075         OTHER      = 3,
0076         MIXEDTYPES = -1
0077     };
0078 
0079 public:
0080 
0081     explicit FlickrList(QWidget* const parent = nullptr, bool = false);
0082 
0083     void setPublic(Qt::CheckState);
0084     void setFamily(Qt::CheckState);
0085     void setFriends(Qt::CheckState);
0086     void setSafetyLevels(SafetyLevel);
0087     void setContentTypes(ContentType);
0088 
0089 Q_SIGNALS:
0090 
0091     // Signal for notifying when the states of one of the permission columns has
0092     // changed. The first argument specifies which permission has changed, the
0093     // second the state.
0094     void signalPermissionChanged(FlickrList::FieldType, Qt::CheckState);
0095 
0096     void signalSafetyLevelChanged(FlickrList::SafetyLevel);
0097     void signalContentTypeChanged(FlickrList::ContentType);
0098 
0099 public Q_SLOTS:
0100 
0101     void slotAddImages(const QList<QUrl>& list) override;
0102 
0103 private:
0104 
0105     void setPermissionState(FieldType, Qt::CheckState);
0106     void singlePermissionChanged(QTreeWidgetItem*, int);
0107     void singleComboBoxChanged(QTreeWidgetItem*, int);
0108 
0109 
0110 private Q_SLOTS:
0111 
0112     void slotItemChanged(QTreeWidgetItem*, int);
0113     void slotItemClicked(QTreeWidgetItem*, int);
0114 
0115 private:
0116 
0117     Qt::CheckState          m_public;
0118     Qt::CheckState          m_family;
0119     Qt::CheckState          m_friends;
0120     FlickrList::SafetyLevel m_safetyLevel;
0121     FlickrList::ContentType m_contentType;
0122 
0123     // Used to separate the ImagesList::itemChanged signals that were caused
0124     // programmatically from those caused by the user.
0125     bool                    m_userIsEditing;
0126 
0127     bool                    m_is23;
0128 };
0129 
0130 // -------------------------------------------------------------------------
0131 
0132 class FlickrListViewItem : public KPImagesListViewItem
0133 {
0134 
0135 public:
0136 
0137     FlickrListViewItem(KPImagesListView* const view, const QUrl& url,
0138                        bool, bool, bool, bool,
0139                        FlickrList::SafetyLevel, FlickrList::ContentType);
0140     ~FlickrListViewItem();
0141 
0142     void setPublic(bool);
0143     void setFamily(bool);
0144     void setFriends(bool);
0145     void setSafetyLevel(FlickrList::SafetyLevel);
0146     void setContentType(FlickrList::ContentType);
0147     bool isPublic() const;
0148     bool isFamily() const;
0149     bool isFriends() const;
0150     FlickrList::SafetyLevel safetyLevel() const;
0151     FlickrList::ContentType contentType() const;
0152 
0153     /**
0154      * Returns the list of extra tags that the user specified for this image.
0155      */
0156     QStringList extraTags() const;
0157 
0158     /** This method should be called when one of the checkboxes is clicked.
0159      */
0160     void toggled();
0161 
0162     void updateItemWidgets() override;
0163 
0164 private:
0165 
0166     bool                    m_is23;
0167 
0168     bool                    m_public;
0169     bool                    m_family;
0170     bool                    m_friends;
0171 
0172     FlickrList::SafetyLevel m_safetyLevel;
0173     FlickrList::ContentType m_contentType;
0174 
0175     /** LineEdit used for extra tags per image.
0176      */
0177     QLineEdit*              m_tagLineEdit;
0178 };
0179 
0180 } // namespace KIPIFlickrPlugin
0181 
0182 #endif /* FLICKRLIST_H */