2018-07-04 23:40:21 +00:00
|
|
|
#include "backend/computermanager.h"
|
2018-07-07 23:30:26 +00:00
|
|
|
#include "streaming/session.hpp"
|
2018-07-04 23:40:21 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
|
|
|
class ComputerModel : public QAbstractListModel
|
|
|
|
{
|
2018-07-06 03:11:35 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-07-04 23:40:21 +00:00
|
|
|
enum Roles
|
|
|
|
{
|
|
|
|
NameRole = Qt::UserRole,
|
|
|
|
OnlineRole,
|
|
|
|
PairedRole,
|
|
|
|
BusyRole,
|
|
|
|
AddPcRole
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2018-07-06 03:11:35 +00:00
|
|
|
explicit ComputerModel(QObject* object = nullptr);
|
2018-07-04 23:40:21 +00:00
|
|
|
|
2018-07-06 05:08:55 +00:00
|
|
|
// Must be called before any QAbstractListModel functions
|
|
|
|
Q_INVOKABLE void initialize(ComputerManager* computerManager);
|
|
|
|
|
2018-07-04 23:40:21 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
|
|
|
|
virtual QHash<int, QByteArray> roleNames() const override;
|
|
|
|
|
2018-07-06 05:08:55 +00:00
|
|
|
Q_INVOKABLE void deleteComputer(int computerIndex);
|
|
|
|
|
2018-07-06 06:12:55 +00:00
|
|
|
Q_INVOKABLE void pairComputer(int computerIndex, QString pin);
|
|
|
|
|
2018-07-06 07:34:16 +00:00
|
|
|
Q_INVOKABLE bool wakeComputer(int computerIndex);
|
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
Q_INVOKABLE Session* createSessionForCurrentGame(int computerIndex);
|
|
|
|
|
2018-07-06 06:12:55 +00:00
|
|
|
signals:
|
|
|
|
void pairingCompleted(QVariant error);
|
|
|
|
|
2018-07-04 23:40:21 +00:00
|
|
|
private slots:
|
|
|
|
void handleComputerStateChanged(NvComputer* computer);
|
|
|
|
|
2018-07-06 06:12:55 +00:00
|
|
|
void handlePairingCompleted(NvComputer* computer, QString error);
|
|
|
|
|
2018-07-04 23:40:21 +00:00
|
|
|
private:
|
|
|
|
QVector<NvComputer*> m_Computers;
|
2018-07-06 05:08:55 +00:00
|
|
|
ComputerManager* m_ComputerManager;
|
2018-07-04 23:40:21 +00:00
|
|
|
};
|