Falkon Develop
Cross-platform Qt-based web browser
downloaditem.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef DOWNLOADITEM_H
19#define DOWNLOADITEM_H
20
21#include <QWidget>
22#include <QFile>
23#include <QBasicTimer>
24#include <QUrl>
25#include <QNetworkReply>
26#include <QElapsedTimer>
27#include <QTime>
28#include <QElapsedTimer>
29
30#include "qzcommon.h"
31
32namespace Ui
33{
34class DownloadItem;
35}
36
37class QListWidgetItem;
38class QWebEngineDownloadRequest;
39
40class DownloadManager;
41
42class FALKON_EXPORT DownloadItem : public QWidget
43{
44 Q_OBJECT
45
46public:
47 explicit DownloadItem(QListWidgetItem* item, QWebEngineDownloadRequest* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager);
48 bool isDownloading() const { return m_downloading; }
49 bool isCancelled();
50 QTime remainingTime() const { return m_remTime; }
51 double currentSpeed() const { return m_currSpeed; }
52 int progress();
53 QUrl url() const;
54 QString path() const;
55 QString fileName() const;
56 ~DownloadItem() override;
57 void setDownTimer(const QElapsedTimer &timer) { m_downTimer = timer; }
58
59 void startDownloading();
60
61 static QString remaingTimeToString(QTime time);
62 static QString currentSpeedToString(double speed);
63
64Q_SIGNALS:
66 void downloadFinished(bool success);
67 void progressChanged(double currSpeed, qint64 received, qint64 total);
68
69private Q_SLOTS:
70 void parentResized(const QSize &size);
71 void finished();
72 void receivedOrTotalBytesChanged();
73 void stop();
74 void pauseResume();
75 void openFile();
76 void openFolder();
77 void customContextMenuRequested(const QPoint &pos);
78 void clear();
79
80 void copyDownloadLink();
81
82private:
83 void updateDownloadInfo(double currSpeed, qint64 received, qint64 total);
84 void mouseDoubleClickEvent(QMouseEvent* e) override;
85
86 Ui::DownloadItem* ui;
87
88 QListWidgetItem* m_item;
89 QWebEngineDownloadRequest* m_download;
90 QString m_path;
91 QString m_fileName;
92 QElapsedTimer m_downTimer;
93 QTime m_remTime;
94 QUrl m_downUrl;
95 bool m_openFile;
96
97 bool m_downloading;
98 bool m_downloadStopped;
99 double m_currSpeed;
100 qint64 m_received;
101 qint64 m_total;
102};
103
104#endif // DOWNLOADITEM_H
QTime remainingTime() const
Definition: downloaditem.h:50
void setDownTimer(const QElapsedTimer &timer)
Definition: downloaditem.h:57
void downloadFinished(bool success)
bool isDownloading() const
Definition: downloaditem.h:48
void deleteItem(DownloadItem *)
void progressChanged(double currSpeed, qint64 received, qint64 total)
double currentSpeed() const
Definition: downloaditem.h:51
#define FALKON_EXPORT
Definition: qzcommon.h:28