-
Notifications
You must be signed in to change notification settings - Fork 1
/
argoqmlcontext.h
executable file
·50 lines (42 loc) · 1.52 KB
/
argoqmlcontext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef ARGOQMLCONTEXT_H
#define ARGOQMLCONTEXT_H
#include <QObject>
#include <memory>
#include "ArgoLoader.h"
#include "qtorrentlistmodel.h"
#include "torrentobserver.h"
class ArgoQMLContext : public QObject
{
Q_OBJECT
public:
// This just holds the info we need for a torrent in one place
class TorrentContext {
public:
TorrentContext() :
name(QString::null), argo_torrent(nullptr)
{
q_torrent = QSharedPointer<QTorrentObject>::create();
}
QString name;
QSharedPointer<QTorrentObject> q_torrent;
std::shared_ptr<Argo::Torrent> argo_torrent;
};
explicit ArgoQMLContext(QObject *parent = 0);
Q_INVOKABLE void loadTorrentClicked( const QString& filePath);
void NotifyOfBytesReceived(int bytes) { emit bytesReceived(bytes); }
void NotifyOfTotalProgress(int progress) { emit totalProgress(progress); }
std::shared_ptr<Argo::Universe> getUniverse() const { return _universe; }
QTorrentListModel* getTorrentListModel() { return &_qt_list_model; }
std::shared_ptr<TorrentContext> lookupTorrent(const Argo::SHA1Hash& hash);
std::shared_ptr<TorrentContext> addTorrent(const Argo::SHA1Hash& hash);
signals:
void bytesReceived(int bytes);
void totalProgress(int progress);
public slots:
private:
std::shared_ptr<Argo::Universe> _universe;
QTorrentListModel _qt_list_model;
std::map<Argo::SHA1Hash, std::shared_ptr<TorrentContext>> _torrents;
std::shared_ptr<TorrentListObserver> _tlo;
};
#endif // ARGOQMLCONTEXT_H