File indexing completed on 2025-01-05 03:53:36

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2011-03-22
0007  * Description : a Iface C++ interface
0008  *
0009  * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2011      by Ludovic Delfau <ludovicdelfau at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_MEDIAWIKI_QUERYIMAGEINFO_H
0017 #define DIGIKAM_MEDIAWIKI_QUERYIMAGEINFO_H
0018 
0019 // Qt includes
0020 
0021 #include <QList>
0022 
0023 // Local includes
0024 
0025 #include "mediawiki_imageinfo.h"
0026 #include "mediawiki_job.h"
0027 
0028 namespace MediaWiki
0029 {
0030 
0031 class Iface;
0032 class QueryImageinfoPrivate;
0033 
0034 /**
0035  * @brief Query image info job.
0036  *
0037  * Gets image information for an image.
0038  */
0039 class QueryImageinfo : public Job
0040 {
0041     Q_OBJECT
0042     Q_DECLARE_PRIVATE(QueryImageinfo)
0043 
0044 public:
0045 
0046     /**
0047     * @brief Property.
0048     */
0049     enum Property
0050     {
0051         Timestamp = 0x01,
0052         User      = 0x02,
0053         Comment   = 0x04,
0054         Url       = 0x08,
0055         Size      = 0x10,
0056         Sha1      = 0x20,
0057         Mime      = 0x40,
0058         Metadata  = 0x80
0059     };
0060     Q_DECLARE_FLAGS(Properties, Property)
0061 
0062 public:
0063 
0064     /**
0065      * @brief Constructs a query image info job.
0066      *
0067      * You can set parameters of the query after.
0068      *
0069      * By default, a single image info is returned.
0070      *
0071      * @param MediaWiki the MediaWiki concerned by the job
0072      * @param parent the QObject parent
0073      */
0074     explicit QueryImageinfo(Iface& MediaWiki, QObject* const parent = nullptr);
0075 
0076     /**
0077      * @brief Destructs a query image info job.
0078      */
0079     ~QueryImageinfo() override;
0080 
0081     /**
0082      * @brief Set the title of the image requested.
0083      * @param title the title of the image requested
0084      */
0085     void setTitle(const QString& title);
0086 
0087     /**
0088      * @brief Set which properties to get.
0089      * @param properties the properties to get
0090      */
0091     void setProperties(Properties properties);
0092 
0093     /**
0094      * @brief Set how many image info to return per signal.
0095      * @param limit how many image info to return per signal
0096      */
0097     void setLimit(unsigned int limit);
0098 
0099     /**
0100      * @brief If true stop the request to the first signal.
0101      * @param onlyOneSignal if true stop the request to the first signal
0102      */
0103     void setOnlyOneSignal(bool onlyOneSignal);
0104 
0105     /**
0106      * @brief Set timestamp to start listing from.
0107      * @param begin timestamp to start listing from
0108      */
0109     void setBeginTimestamp(const QDateTime& begin);
0110 
0111     /**
0112      * @brief Set timestamp to stop listing at.
0113      * @param end timestamp to stop listing at
0114      */
0115     void setEndTimestamp(const QDateTime& end);
0116 
0117     /**
0118      * @brief Set width scale.
0119      *
0120      * Only for the first image info. The property URL must be set.
0121      *
0122      * @param width the width scale
0123      */
0124     void setWidthScale(unsigned int width);
0125 
0126     /**
0127      * @brief Set height scale.
0128      *
0129      * Only for the first image info. The property URL must be set.
0130      *
0131      * @param height the height scale
0132      */
0133     void setHeightScale(unsigned int height);
0134 
0135     /**
0136      * @brief Starts the job asynchronously.
0137      */
0138     void start() override;
0139 
0140 Q_SIGNALS:
0141 
0142     /**
0143     * @brief Provides a list of imageinfos.
0144     * @param imageinfos a list of imageinfos
0145     */
0146     void result(const QList<Imageinfo>& imageinfos);
0147 
0148 private Q_SLOTS:
0149 
0150     void doWorkSendRequest();
0151     void doWorkProcessReply();
0152 };
0153 
0154 Q_DECLARE_OPERATORS_FOR_FLAGS(QueryImageinfo::Properties)
0155 
0156 } // namespace MediaWiki
0157 
0158 #endif // DIGIKAM_MEDIAWIKI_QUERYIMAGEINFO_H