digiKam
filesdownloader.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2020-11-14
7  * Description : Files downloader
8  *
9  * Copyright (C) 2020-2021 by Maik Qualmann <metzpinguin at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_FILES_DOWNLOADER_H
25 #define DIGIKAM_FILES_DOWNLOADER_H
26 
27 // Qt includes
28 
29 #include <QDialog>
30 #include <QNetworkReply>
31 
32 // Local includes
33 
34 #include "digikam_export.h"
35 
36 namespace Digikam
37 {
38 
39 // ----------------------------------------------------------------------------
40 
41 class DIGIKAM_EXPORT DownloadInfo
42 {
43 public:
44 
45  DownloadInfo();
46  DownloadInfo(const QString& _path,
47  const QString& _name,
48  const QString& _hash,
49  const qint64& _size);
50  DownloadInfo(const DownloadInfo& other);
51  ~DownloadInfo();
52 
53  DownloadInfo& operator=(const DownloadInfo& other);
54 
58  QString path;
59 
63  QString name;
64 
68  QString hash;
69 
73  qint64 size;
74 };
75 
76 // ----------------------------------------------------------------------------
77 
78 class DIGIKAM_EXPORT FilesDownloader : public QDialog
79 {
80  Q_OBJECT
81 
82 public:
83 
84  explicit FilesDownloader(QWidget* const parent = nullptr);
85  ~FilesDownloader() override;
86 
87  bool checkDownloadFiles() const;
88  void startDownload();
89 
90 private:
91 
92  void download();
93  void nextDownload();
94  void createRequest(const QUrl& url);
95  void printDownloadInfo(const QUrl& url);
96  bool downloadExists(const DownloadInfo& info) const;
97 
98  QString getFacesEnginePath() const;
99 
100 private Q_SLOTS:
101 
102  void reject() override;
103  void slotDownload();
104  void slotDownloaded(QNetworkReply* reply);
105  void slotDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
106 
107 private:
108 
109  // Disable
110  FilesDownloader(const FilesDownloader&) = delete;
111  FilesDownloader& operator=(const FilesDownloader&) = delete;
112 
113 private:
114 
115  class Private;
116  Private* const d;
117 };
118 
119 } // namespace Digikam
120 
121 #endif // DIGIKAM_FILES_DOWNLOADER_H
Definition: filesdownloader.h:42
QString hash
Definition: filesdownloader.h:68
qint64 size
Definition: filesdownloader.h:73
QString path
Definition: filesdownloader.h:58
QString name
Definition: filesdownloader.h:63
Definition: filesdownloader.h:79
Definition: datefolderview.cpp:43