2018-07-04 23:40:21 +00:00
|
|
|
#include "backend/computermanager.h"
|
2018-09-29 23:18:46 +00:00
|
|
|
#include "streaming/session.h"
|
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,
|
2018-08-01 05:10:38 +00:00
|
|
|
WakeableRole,
|
2021-05-01 01:05:38 +00:00
|
|
|
StatusUnknownRole,
|
|
|
|
ServerSupportedRole
|
2018-07-04 23:40:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2020-07-12 20:19:26 +00:00
|
|
|
Q_INVOKABLE QString generatePinString();
|
|
|
|
|
2018-07-06 06:12:55 +00:00
|
|
|
Q_INVOKABLE void pairComputer(int computerIndex, QString pin);
|
|
|
|
|
2020-08-09 03:25:26 +00:00
|
|
|
Q_INVOKABLE void testConnectionForComputer(int computerIndex);
|
|
|
|
|
2018-09-05 23:10:32 +00:00
|
|
|
Q_INVOKABLE void wakeComputer(int computerIndex);
|
2018-07-06 07:34:16 +00:00
|
|
|
|
2020-05-02 01:34:15 +00:00
|
|
|
Q_INVOKABLE void renameComputer(int computerIndex, QString name);
|
|
|
|
|
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);
|
2020-08-09 03:25:26 +00:00
|
|
|
void connectionTestCompleted(int result, QString blockedPorts);
|
2018-07-06 06:12:55 +00:00
|
|
|
|
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
|
|
|
};
|