1 /***************************************************************************
2     Copyright (C) 2017 Robby Stephenson <robby@periapsis.org>
3  ***************************************************************************/
4 
5 /***************************************************************************
6  *                                                                         *
7  *   This program is free software; you can redistribute it and/or         *
8  *   modify it under the terms of the GNU General Public License as        *
9  *   published by the Free Software Foundation; either version 2 of        *
10  *   the License or (at your option) version 3 or any later version        *
11  *   accepted by the membership of KDE e.V. (or its successor approved     *
12  *   by the membership of KDE e.V.), which shall act as a proxy            *
13  *   defined in Section 14 of version 3 of the license.                    *
14  *                                                                         *
15  *   This program is distributed in the hope that it will be useful,       *
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
18  *   GNU General Public License for more details.                          *
19  *                                                                         *
20  *   You should have received a copy of the GNU General Public License     *
21  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
22  *                                                                         *
23  ***************************************************************************/
24 
25 #ifndef TELLICO_IMAGEJOB_H
26 #define TELLICO_IMAGEJOB_H
27 
28 #include <KIO/Job>
29 
30 #include "image.h"
31 
32 namespace Tellico {
33 
34 /**
35  * @author Robby Stephenson
36  */
37 class ImageJob : public KIO::Job {
38 Q_OBJECT
39 
40 public:
41   ImageJob(const QUrl& url, const QString& id = QString(), bool quiet=false);
42   virtual ~ImageJob();
43 
44   virtual QString errorString() const Q_DECL_OVERRIDE;
url()45   QUrl url() const { return m_url; }
linkOnly()46   bool linkOnly() const { return m_linkOnly; }
47   const Data::Image& image() const;
48 
49   void setLinkOnly(bool linkOnly);
50   void setReferrer(const QUrl& referrer);
51 
52 private Q_SLOTS:
53   void slotStart();
54   void getJobResult(KJob* job);
55 
56 private:
57   QUrl m_url;
58   QString m_id;
59   bool m_linkOnly;
60   bool m_quiet;
61   QUrl m_referrer;
62   Data::Image m_image;
63 };
64 
65 } // end namespace
66 
67 
68 #endif
69