File indexing completed on 2024-04-28 12:31:13
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-2013 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 * @author Copyright (C) 2010 by Paolo de Vathaire 0015 * <a href="mailto:paolo dot devathaire at gmail dot com">paolo dot devathaire at gmail dot com</a> 0016 * 0017 * This program is free software; you can redistribute it 0018 * and/or modify it under the terms of the GNU General 0019 * Public License as published by the Free Software Foundation; 0020 * either version 2, or (at your option) 0021 * any later version. 0022 * 0023 * This program is distributed in the hope that it will be useful, 0024 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0026 * GNU General Public License for more details. 0027 * 0028 * ============================================================ */ 0029 0030 #ifndef MEDIAWIKI_QUERYIMAGES_H 0031 #define MEDIAWIKI_QUERYIMAGES_H 0032 0033 // KF includes 0034 0035 #include <KJob> 0036 0037 // Local includes 0038 0039 #include "job.h" 0040 #include "mediawiki_export.h" 0041 #include "image.h" 0042 0043 namespace mediawiki 0044 { 0045 0046 class MediaWiki; 0047 class QueryImagesPrivate; 0048 0049 /** 0050 * @brief Query images job. 0051 * 0052 * Gets a list of all images used on pages. 0053 */ 0054 class MEDIAWIKI_EXPORT QueryImages : public Job 0055 { 0056 Q_OBJECT 0057 Q_DECLARE_PRIVATE(QueryImages) 0058 0059 public: 0060 0061 /** 0062 * @brief Indicates all possible error conditions found during the processing of the job. 0063 */ 0064 enum 0065 { 0066 /** 0067 * @brief A network error has occurred. 0068 */ 0069 NetworkError = KJob::UserDefinedError + 1, 0070 0071 /** 0072 * @brief A XML error has occurred. 0073 */ 0074 XmlError 0075 }; 0076 0077 public: 0078 0079 /** 0080 * @brief Constructs a query images job. 0081 * @param mediawiki the mediawiki concerned by the job 0082 * @param parent the QObject parent 0083 */ 0084 explicit QueryImages(MediaWiki& mediawiki, QObject* const parent = nullptr); 0085 0086 /** 0087 * @brief Destroys a query images job. 0088 */ 0089 ~QueryImages() override; 0090 0091 /** 0092 * @brief Set the title. 0093 * @param title the title of the page 0094 */ 0095 void setTitle(const QString& title); 0096 0097 /** 0098 * @brief Set the limit. 0099 * @param limit number of images returned by one signal #pages() 0100 */ 0101 void setLimit(unsigned int limit); 0102 0103 /** 0104 * @brief Starts the job asynchronously. 0105 */ 0106 void start() override; 0107 0108 Q_SIGNALS: 0109 0110 /** 0111 * @brief Provides a list of all images used on pages 0112 * 0113 * This signal can be emitted several times. 0114 * 0115 * @param pages list of all images used on pages 0116 */ 0117 void images(const QList<Image> & images); 0118 0119 private Q_SLOTS: 0120 0121 void doWorkSendRequest(); 0122 void doWorkProcessReply(); 0123 }; 0124 0125 } // namespace mediawiki 0126 0127 #endif // MEDIAWIKI_QUERYIMAGES_H