kasts/src/enclosure.h

80 lines
2.0 KiB
C
Raw Normal View History

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
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)
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)
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;
Status status() const;
2021-04-10 22:28:36 +02:00
qint64 playPosition() const;
qint64 duration() const;
int size() const;
2021-04-10 22:28:36 +02:00
void setPlayPosition(const qint64 &position);
void setDuration(const qint64 &duration);
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();
void durationChanged();
void sizeChanged();
2021-02-21 19:54:10 +01:00
private:
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