File indexing completed on 2024-03-24 16:13:24
0001 /** =========================================================== 0002 * @file 0003 * 0004 * This file is a part of KDE project 0005 * <a href="https://commits.kde.org/libmediawiki">libmediawiki</a> 0006 * 0007 * @date 2011-03-22 0008 * @brief a MediaWiki C++ interface for KDE 0009 * 0010 * @author Copyright (C) 2011-2012 by Gilles Caulier 0011 * <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a> 0012 * @author Copyright (C) 2010 by Ludovic Delfau 0013 * <a href="mailto:ludovicdelfau at gmail dot com">ludovicdelfau at gmail dot com</a> 0014 * 0015 * This program is free software; you can redistribute it 0016 * and/or modify it under the terms of the GNU General 0017 * Public License as published by the Free Software Foundation; 0018 * either version 2, or (at your option) 0019 * any later version. 0020 * 0021 * This program is distributed in the hope that it will be useful, 0022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0024 * GNU General Public License for more details. 0025 * 0026 * ============================================================ */ 0027 0028 #ifndef MEDIAWIKI_QUERYIMAGEINFO_H 0029 #define MEDIAWIKI_QUERYIMAGEINFO_H 0030 0031 // Qt includes 0032 0033 #include <QList> 0034 0035 // Local includes 0036 0037 #include "imageinfo.h" 0038 #include "job.h" 0039 #include "mediawiki_export.h" 0040 0041 namespace mediawiki 0042 { 0043 0044 class MediaWiki; 0045 class QueryImageinfoPrivate; 0046 0047 /** 0048 * @brief Query image info job. 0049 * 0050 * Gets image information for an image. 0051 */ 0052 class MEDIAWIKI_EXPORT QueryImageinfo : public Job 0053 { 0054 Q_OBJECT 0055 Q_DECLARE_PRIVATE(QueryImageinfo) 0056 0057 public: 0058 0059 /** 0060 * @brief Property. 0061 */ 0062 enum Property 0063 { 0064 Timestamp = 0x01, 0065 User = 0x02, 0066 Comment = 0x04, 0067 Url = 0x08, 0068 Size = 0x10, 0069 Sha1 = 0x20, 0070 Mime = 0x40, 0071 Metadata = 0x80 0072 }; 0073 Q_DECLARE_FLAGS(Properties, Property) 0074 0075 public: 0076 0077 /** 0078 * @brief Constructs a query image info job. 0079 * 0080 * You can set parameters of the query after. 0081 * 0082 * By default, a single image info is returned. 0083 * 0084 * @param mediawiki the mediawiki concerned by the job 0085 * @param parent the QObject parent 0086 */ 0087 explicit QueryImageinfo(MediaWiki& mediawiki, QObject* const parent = nullptr); 0088 0089 /** 0090 * @brief Destructs a query image info job. 0091 */ 0092 ~QueryImageinfo() override; 0093 0094 /** 0095 * @brief Set the title of the image requested. 0096 * @param title the title of the image requested 0097 */ 0098 void setTitle(const QString& title); 0099 0100 /** 0101 * @brief Set which properties to get. 0102 * @param properties properties to get 0103 */ 0104 void setProperties(Properties properties); 0105 0106 /** 0107 * @brief Set how many image info to return per signal. 0108 * @param limit how many image info to return per signal 0109 */ 0110 void setLimit(unsigned int limit); 0111 0112 /** 0113 * @brief If true stop the request to the first signal. 0114 * @param onlyOneSignal if true stop the request to the first signal 0115 */ 0116 void setOnlyOneSignal(bool onlyOneSignal); 0117 0118 /** 0119 * @brief Set timestamp to start listing from. 0120 * @param begin timestamp to start listing from 0121 */ 0122 void setBeginTimestamp(const QDateTime& begin); 0123 0124 /** 0125 * @brief Set timestamp to stop listing at. 0126 * @param end timestamp to stop listing at 0127 */ 0128 void setEndTimestamp(const QDateTime& end); 0129 0130 /** 0131 * @brief Set width scale. 0132 * 0133 * Only for the first image info. The property URL must be set. 0134 * 0135 * @param width width scale 0136 */ 0137 void setWidthScale(unsigned int width); 0138 0139 /** 0140 * @brief Set height scale. 0141 * 0142 * Only for the first image info. The property URL must be set. 0143 * 0144 * @param height height scale 0145 */ 0146 void setHeightScale(unsigned int height); 0147 0148 /** 0149 * @brief Starts the job asynchronously. 0150 */ 0151 void start() override; 0152 0153 Q_SIGNALS: 0154 0155 /** 0156 * @brief Provides a list of imageinfos. 0157 * @param imageinfos a list of imageinfos 0158 */ 0159 void result(const QList<Imageinfo>& imageinfos); 0160 0161 private Q_SLOTS: 0162 0163 void doWorkSendRequest(); 0164 void doWorkProcessReply(); 0165 }; 0166 0167 Q_DECLARE_OPERATORS_FOR_FLAGS(QueryImageinfo::Properties) 0168 0169 } // namespace mediawiki 0170 0171 #endif // MEDIAWIKI_QUERYIMAGEINFO_H