Load class TellStick for TellStick controllers
This commit is contained in:
parent
a2f8d08511
commit
3b137c0326
2 changed files with 13 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "controllerlist.h"
|
#include "controllerlist.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
#include "tellstick.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ ControllerList::ControllerList(QObject *parent) :
|
||||||
char name[DATA_LENGTH];
|
char name[DATA_LENGTH];
|
||||||
int available, controllerId, type;
|
int available, controllerId, type;
|
||||||
while(tdController(&controllerId, &type, name, DATA_LENGTH, &available) == TELLSTICK_SUCCESS) {
|
while(tdController(&controllerId, &type, name, DATA_LENGTH, &available) == TELLSTICK_SUCCESS) {
|
||||||
Controller *controller = new Controller(controllerId, type, QString::fromUtf8(name), this);
|
Controller *controller = loadController(controllerId, type, QString::fromUtf8(name), this);
|
||||||
controller->setAvailable(available);
|
controller->setAvailable(available);
|
||||||
connect(controller, SIGNAL(nameChanged()), this, SIGNAL(changed()));
|
connect(controller, SIGNAL(nameChanged()), this, SIGNAL(changed()));
|
||||||
d->list.append(controller);
|
d->list.append(controller);
|
||||||
|
@ -72,7 +73,7 @@ void ControllerList::controllerEventSlot(int controllerId, int changeEvent, int
|
||||||
|
|
||||||
if (changeEvent == TELLSTICK_DEVICE_ADDED) {
|
if (changeEvent == TELLSTICK_DEVICE_ADDED) {
|
||||||
beginInsertRows( QModelIndex(), d->list.size(), d->list.size() );
|
beginInsertRows( QModelIndex(), d->list.size(), d->list.size() );
|
||||||
Controller *controller = new Controller(controllerId, changeType, "", this);
|
Controller *controller = loadController(controllerId, changeType, "", this);
|
||||||
controller->setAvailable(true);
|
controller->setAvailable(true);
|
||||||
connect(controller, SIGNAL(nameChanged()), this, SIGNAL(changed()));
|
connect(controller, SIGNAL(nameChanged()), this, SIGNAL(changed()));
|
||||||
d->list.append(controller);
|
d->list.append(controller);
|
||||||
|
@ -93,6 +94,13 @@ void ControllerList::controllerEventSlot(int controllerId, int changeEvent, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controller *ControllerList::loadController(int id, int type, const QString &name, QObject *parent) {
|
||||||
|
if (type == 1) {
|
||||||
|
return new TellStick(id, type, "", parent);
|
||||||
|
}
|
||||||
|
return new Controller(id, type, "", parent);
|
||||||
|
}
|
||||||
|
|
||||||
void WINAPI ControllerList::controllerEvent( int controllerId, int changeEvent, int changeType, const char *newValue, int callbackId, void *context) {
|
void WINAPI ControllerList::controllerEvent( int controllerId, int changeEvent, int changeType, const char *newValue, int callbackId, void *context) {
|
||||||
ControllerList *controllerList = reinterpret_cast<ControllerList *>(context);
|
ControllerList *controllerList = reinterpret_cast<ControllerList *>(context);
|
||||||
if (!controllerList) {
|
if (!controllerList) {
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
#include <telldus-core.h>
|
#include <telldus-core.h>
|
||||||
|
|
||||||
|
class Controller;
|
||||||
|
|
||||||
class ControllerList : public QAbstractListModel
|
class ControllerList : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -27,6 +29,7 @@ private slots:
|
||||||
void controllerEventSlot(int controllerId, int changeEvent, int changeType, const QString &newValue);
|
void controllerEventSlot(int controllerId, int changeEvent, int changeType, const QString &newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static Controller *loadController(int id, int type, const QString &name, QObject *parent);
|
||||||
static void WINAPI controllerEvent( int controllerId, int changeEvent, int changeType, const char *newValue, int callbackId, void *context);
|
static void WINAPI controllerEvent( int controllerId, int changeEvent, int changeType, const char *newValue, int callbackId, void *context);
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
PrivateData *d;
|
PrivateData *d;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue