2021-02-21 19:54:10 +01:00
|
|
|
/**
|
|
|
|
* SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de>
|
2021-04-11 20:30:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
|
2021-02-21 19:54:10 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ENCLOSURE_H
|
|
|
|
#define ENCLOSURE_H
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
class Entry;
|
|
|
|
|
|
|
|
class Enclosure : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2021-04-18 22:31:55 +02:00
|
|
|
Q_PROPERTY(int size READ size WRITE setSize NOTIFY sizeChanged)
|
2021-02-21 19:54:10 +01:00
|
|
|
Q_PROPERTY(QString title MEMBER m_title CONSTANT)
|
|
|
|
Q_PROPERTY(QString type MEMBER m_type CONSTANT)
|
|
|
|
Q_PROPERTY(QString url MEMBER m_url CONSTANT)
|
2021-04-13 20:51:00 +02:00
|
|
|
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
|
2021-02-21 19:54:10 +01:00
|
|
|
Q_PROPERTY(double downloadProgress MEMBER m_downloadProgress NOTIFY downloadProgressChanged)
|
|
|
|
Q_PROPERTY(QString path READ path CONSTANT)
|
2021-04-10 22:28:36 +02:00
|
|
|
Q_PROPERTY(qint64 playPosition READ playPosition WRITE setPlayPosition NOTIFY playPositionChanged)
|
2021-04-18 22:21:59 +02:00
|
|
|
Q_PROPERTY(qint64 duration READ duration WRITE setDuration NOTIFY durationChanged)
|
2021-02-21 19:54:10 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
Enclosure(Entry *entry);
|
|
|
|
|
|
|
|
enum Status {
|
|
|
|
Downloadable,
|
|
|
|
Downloading,
|
|
|
|
Downloaded,
|
|
|
|
Error,
|
|
|
|
};
|
|
|
|
Q_ENUM(Status)
|
|
|
|
|
|
|
|
Q_INVOKABLE void download();
|
|
|
|
Q_INVOKABLE void deleteFile();
|
|
|
|
|
|
|
|
QString path() const;
|
2021-04-13 20:51:00 +02:00
|
|
|
Status status() const;
|
2021-04-10 22:28:36 +02:00
|
|
|
qint64 playPosition() const;
|
2021-04-18 22:21:59 +02:00
|
|
|
qint64 duration() const;
|
2021-04-18 22:31:55 +02:00
|
|
|
int size() const;
|
2021-04-18 22:21:59 +02:00
|
|
|
|
2021-04-10 22:28:36 +02:00
|
|
|
void setPlayPosition(const qint64 &position);
|
2021-04-18 22:21:59 +02:00
|
|
|
void setDuration(const qint64 &duration);
|
2021-04-18 22:31:55 +02:00
|
|
|
void setSize(const int &size);
|
2021-02-21 19:54:10 +01:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void statusChanged();
|
|
|
|
void downloadProgressChanged();
|
|
|
|
void cancelDownload();
|
2021-04-10 22:28:36 +02:00
|
|
|
void playPositionChanged();
|
2021-04-18 22:21:59 +02:00
|
|
|
void durationChanged();
|
2021-04-18 22:31:55 +02:00
|
|
|
void sizeChanged();
|
2021-02-21 19:54:10 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2021-04-09 22:32:13 +02:00
|
|
|
void processDownloadedFile();
|
|
|
|
|
2021-02-21 19:54:10 +01:00
|
|
|
Entry *m_entry;
|
2021-04-13 22:48:09 +02:00
|
|
|
qint64 m_duration;
|
2021-02-21 19:54:10 +01:00
|
|
|
int m_size;
|
|
|
|
QString m_title;
|
|
|
|
QString m_type;
|
|
|
|
QString m_url;
|
2021-04-10 22:28:36 +02:00
|
|
|
qint64 m_playposition;
|
|
|
|
qint64 m_playposition_dbsave;
|
2021-02-21 19:54:10 +01:00
|
|
|
double m_downloadProgress = 0;
|
|
|
|
Status m_status;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ENCLOSURE_H
|