fix some crashers
This commit is contained in:
parent
370df7d047
commit
3c3cb76bf8
@ -73,6 +73,7 @@ QVariant ActionTypes::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
void ActionTypes::addActionType(ActionType *actionType)
|
void ActionTypes::addActionType(ActionType *actionType)
|
||||||
{
|
{
|
||||||
|
actionType->setParent(this);
|
||||||
beginInsertRows(QModelIndex(), m_actionTypes.count(), m_actionTypes.count());
|
beginInsertRows(QModelIndex(), m_actionTypes.count(), m_actionTypes.count());
|
||||||
//qDebug() << "ActionTypes: loaded actionType" << actionType->name();
|
//qDebug() << "ActionTypes: loaded actionType" << actionType->name();
|
||||||
m_actionTypes.append(actionType);
|
m_actionTypes.append(actionType);
|
||||||
|
|||||||
@ -74,6 +74,10 @@ ParamTypes *EventType::paramTypes() const
|
|||||||
|
|
||||||
void EventType::setParamTypes(ParamTypes *paramTypes)
|
void EventType::setParamTypes(ParamTypes *paramTypes)
|
||||||
{
|
{
|
||||||
|
if (m_paramTypes && m_paramTypes->parent() == this) {
|
||||||
|
m_paramTypes->deleteLater();
|
||||||
|
}
|
||||||
|
paramTypes->setParent(this);
|
||||||
m_paramTypes = paramTypes;
|
m_paramTypes = paramTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ private:
|
|||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
int m_index;
|
int m_index;
|
||||||
ParamTypes *m_paramTypes;
|
ParamTypes *m_paramTypes = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EVENTTYPE_H
|
#endif // EVENTTYPE_H
|
||||||
|
|||||||
@ -71,6 +71,7 @@ QVariant EventTypes::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
void EventTypes::addEventType(EventType *eventType)
|
void EventTypes::addEventType(EventType *eventType)
|
||||||
{
|
{
|
||||||
|
eventType->setParent(this);
|
||||||
beginInsertRows(QModelIndex(), m_eventTypes.count(), m_eventTypes.count());
|
beginInsertRows(QModelIndex(), m_eventTypes.count(), m_eventTypes.count());
|
||||||
//qDebug() << "EventTypes: loaded eventType" << eventType->name();
|
//qDebug() << "EventTypes: loaded eventType" << eventType->name();
|
||||||
m_eventTypes.append(eventType);
|
m_eventTypes.append(eventType);
|
||||||
|
|||||||
@ -15,7 +15,7 @@ Interfaces::Interfaces(QObject *parent) : QAbstractListModel(parent)
|
|||||||
ParamType* pt = nullptr;
|
ParamType* pt = nullptr;
|
||||||
ParamTypes *pts = nullptr;
|
ParamTypes *pts = nullptr;
|
||||||
|
|
||||||
iface = new Interface("battery", "Battery powered devices");
|
iface = new Interface("battery", "Battery powered devices", this);
|
||||||
et = new EventType();
|
et = new EventType();
|
||||||
pts = new ParamTypes(et);
|
pts = new ParamTypes(et);
|
||||||
et->setParamTypes(pts);
|
et->setParamTypes(pts);
|
||||||
@ -43,7 +43,7 @@ Interfaces::Interfaces(QObject *parent) : QAbstractListModel(parent)
|
|||||||
m_list.append(iface);
|
m_list.append(iface);
|
||||||
|
|
||||||
|
|
||||||
iface = new Interface("notification", "Notification services");
|
iface = new Interface("notification", "Notification services", this);
|
||||||
at = new ActionType();
|
at = new ActionType();
|
||||||
pts = new ParamTypes(at);
|
pts = new ParamTypes(at);
|
||||||
at->setParamTypes(pts);
|
at->setParamTypes(pts);
|
||||||
|
|||||||
@ -100,6 +100,7 @@ QVariant ParamTypes::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
void ParamTypes::addParamType(ParamType *paramType)
|
void ParamTypes::addParamType(ParamType *paramType)
|
||||||
{
|
{
|
||||||
|
paramType->setParent(this);
|
||||||
beginInsertRows(QModelIndex(), m_paramTypes.count(), m_paramTypes.count());
|
beginInsertRows(QModelIndex(), m_paramTypes.count(), m_paramTypes.count());
|
||||||
//qDebug() << "ParamTypes: loaded paramType" << paramType->name();
|
//qDebug() << "ParamTypes: loaded paramType" << paramType->name();
|
||||||
m_paramTypes.append(paramType);
|
m_paramTypes.append(paramType);
|
||||||
|
|||||||
@ -44,7 +44,6 @@ QUuid State::stateTypeId() const
|
|||||||
|
|
||||||
QVariant State::value() const
|
QVariant State::value() const
|
||||||
{
|
{
|
||||||
qDebug() << "returning value:" << m_value;
|
|
||||||
return m_value;
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -309,6 +309,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
|||||||
int commandId = dataMap.value("id").toInt();
|
int commandId = dataMap.value("id").toInt();
|
||||||
JsonRpcReply *reply = m_replies.take(commandId);
|
JsonRpcReply *reply = m_replies.take(commandId);
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
reply->deleteLater();
|
||||||
// qDebug() << QString("JsonRpc: got response for %1.%2: %3").arg(reply->nameSpace(), reply->method(), QString::fromUtf8(jsonDoc.toJson(QJsonDocument::Indented))) << reply->callback() << reply->callback();
|
// qDebug() << QString("JsonRpc: got response for %1.%2: %3").arg(reply->nameSpace(), reply->method(), QString::fromUtf8(jsonDoc.toJson(QJsonDocument::Indented))) << reply->callback() << reply->callback();
|
||||||
|
|
||||||
if (dataMap.value("status").toString() == "unauthorized") {
|
if (dataMap.value("status").toString() == "unauthorized") {
|
||||||
@ -322,7 +323,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
|||||||
emit authenticationRequiredChanged();
|
emit authenticationRequiredChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply->caller() != nullptr && !reply->callback().isEmpty()) {
|
if (!reply->caller().isNull() && !reply->callback().isEmpty()) {
|
||||||
QMetaObject::invokeMethod(reply->caller(), reply->callback().toLatin1().data(), Q_ARG(QVariantMap, dataMap));
|
QMetaObject::invokeMethod(reply->caller(), reply->callback().toLatin1().data(), Q_ARG(QVariantMap, dataMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,8 +347,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonRpcReply::JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params, QObject *caller, const QString &callback):
|
JsonRpcReply::JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params, QPointer<QObject> caller, const QString &callback):
|
||||||
QObject(caller),
|
|
||||||
m_commandId(commandId),
|
m_commandId(commandId),
|
||||||
m_nameSpace(nameSpace),
|
m_nameSpace(nameSpace),
|
||||||
m_method(method),
|
m_method(method),
|
||||||
@ -357,6 +357,10 @@ JsonRpcReply::JsonRpcReply(int commandId, QString nameSpace, QString method, QVa
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JsonRpcReply::~JsonRpcReply()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int JsonRpcReply::commandId() const
|
int JsonRpcReply::commandId() const
|
||||||
{
|
{
|
||||||
return m_commandId;
|
return m_commandId;
|
||||||
@ -388,7 +392,7 @@ QVariantMap JsonRpcReply::requestMap()
|
|||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* JsonRpcReply::caller() const
|
QPointer<QObject> JsonRpcReply::caller() const
|
||||||
{
|
{
|
||||||
return m_caller;
|
return m_caller;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
#include "nymeaconnection.h"
|
#include "nymeaconnection.h"
|
||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
@ -115,7 +116,8 @@ class JsonRpcReply : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params = QVariantMap(), QObject *caller = 0, const QString &callback = QString());
|
explicit JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params = QVariantMap(), QPointer<QObject> caller = QPointer<QObject>(), const QString &callback = QString());
|
||||||
|
~JsonRpcReply();
|
||||||
|
|
||||||
int commandId() const;
|
int commandId() const;
|
||||||
QString nameSpace() const;
|
QString nameSpace() const;
|
||||||
@ -123,7 +125,7 @@ public:
|
|||||||
QVariantMap params() const;
|
QVariantMap params() const;
|
||||||
QVariantMap requestMap();
|
QVariantMap requestMap();
|
||||||
|
|
||||||
QObject *caller() const;
|
QPointer<QObject> caller() const;
|
||||||
QString callback() const;
|
QString callback() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -132,7 +134,7 @@ private:
|
|||||||
QString m_method;
|
QString m_method;
|
||||||
QVariantMap m_params;
|
QVariantMap m_params;
|
||||||
|
|
||||||
QObject *m_caller;
|
QPointer<QObject> m_caller;
|
||||||
QString m_callback;
|
QString m_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ Item {
|
|||||||
|
|
||||||
signal addRuleClicked(var value)
|
signal addRuleClicked(var value)
|
||||||
|
|
||||||
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
||||||
|
|
||||||
LogsModel {
|
LogsModel {
|
||||||
id: logs
|
id: logs
|
||||||
|
|||||||
@ -15,106 +15,64 @@ CustomViewBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
property var playbackState: device.states.getState(deviceClass.stateTypes.findByName("playbackStatus").id)
|
property var playbackState: device.states.getState(deviceClass.stateTypes.findByName("playbackStatus").id)
|
||||||
|
property var playbackStateValue: playbackState.value
|
||||||
|
onPlaybackStateValueChanged: populateControls()
|
||||||
|
Component.onCompleted: populateControls()
|
||||||
|
|
||||||
|
function populateControls() {
|
||||||
|
print("generating controls")
|
||||||
|
controlsModel.clear();
|
||||||
|
controlsModel.append({image: "../images/media-skip-backward.svg", action: "skipBack"})
|
||||||
|
controlsModel.append({image: "../images/media-seek-backward.svg", action: "rewind"})
|
||||||
|
controlsModel.append({image: "../images/media-playback-stop.svg", action: "stop"})
|
||||||
|
if (playbackState.value === "PAUSED" || playbackState.value === "STOPPED") {
|
||||||
|
controlsModel.append({image: "../images/media-playback-start.svg", action: "play"})
|
||||||
|
}
|
||||||
|
if (playbackState.value === "PLAYING") {
|
||||||
|
controlsModel.append({image: "../images/media-playback-pause.svg", action: "pause"})
|
||||||
|
}
|
||||||
|
|
||||||
|
controlsModel.append({image: "../images/media-seek-forward.svg", action: "fastForward"})
|
||||||
|
controlsModel.append({image: "../images/media-skip-forward.svg", action: "skipNext"})
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: column
|
id: column
|
||||||
anchors { left: parent.left; right: parent.right }
|
anchors { left: parent.left; right: parent.right }
|
||||||
|
|
||||||
RowLayout {
|
Row {
|
||||||
|
id: controlsRow
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
Item { Layout.fillWidth: true; height: 1 }
|
property int iconSize: Math.max(app.iconSize * 2, column.width / (controlsModel.count + 0))
|
||||||
|
|
||||||
property int iconSize: Math.min(root.width / 6, app.iconSize * 2)
|
// Item {
|
||||||
|
// width: Math.max(app.iconSize * 2, column.width / (controlsModel.count + 2))
|
||||||
|
// height: 1
|
||||||
|
// }
|
||||||
|
|
||||||
AbstractButton {
|
|
||||||
Layout.fillWidth: true
|
Repeater {
|
||||||
height: Math.min(app.iconSize * 2)
|
model: ListModel {
|
||||||
ColorIcon {
|
id: controlsModel
|
||||||
height: parent.height
|
|
||||||
width: height
|
|
||||||
name: "../images/media-skip-backward.svg"
|
|
||||||
}
|
}
|
||||||
onClicked: {
|
delegate: AbstractButton {
|
||||||
executeAction("skipBack")
|
|
||||||
}
|
height: app.iconSize * 2
|
||||||
}
|
width: controlsRow.iconSize
|
||||||
AbstractButton {
|
ColorIcon {
|
||||||
Layout.fillWidth: true
|
height: parent.height
|
||||||
height: Math.min(app.iconSize * 2)
|
width: height
|
||||||
ColorIcon {
|
name: model.image
|
||||||
height: parent.height
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
width: height
|
}
|
||||||
name: "../images/media-seek-backward.svg"
|
onClicked: {
|
||||||
}
|
executeAction(model.action)
|
||||||
onClicked: {
|
}
|
||||||
executeAction("rewind")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AbstractButton {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
height: Math.min(app.iconSize * 2)
|
|
||||||
ColorIcon {
|
|
||||||
height: parent.height
|
|
||||||
width: height
|
|
||||||
name: "../images/media-playback-stop.svg"
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
executeAction("stop")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AbstractButton {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
height: Math.min(app.iconSize * 2)
|
|
||||||
ColorIcon {
|
|
||||||
height: parent.height
|
|
||||||
width: height
|
|
||||||
name: "../images/media-playback-start.svg"
|
|
||||||
}
|
|
||||||
visible: playbackState.value == "PAUSED" || playbackState.value == "STOPPED"
|
|
||||||
onClicked: {
|
|
||||||
executeAction("play")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AbstractButton {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
height: Math.min(app.iconSize * 2)
|
|
||||||
ColorIcon {
|
|
||||||
height: parent.height
|
|
||||||
width: height
|
|
||||||
name: "../images/media-playback-pause.svg"
|
|
||||||
}
|
|
||||||
visible: playbackState.value == "PLAYING"
|
|
||||||
onClicked: {
|
|
||||||
executeAction("pause")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractButton {
|
// Item { Layout.fillWidth: true; height: 1 }
|
||||||
Layout.fillWidth: true
|
|
||||||
height: Math.min(app.iconSize * 2)
|
|
||||||
ColorIcon {
|
|
||||||
height: parent.height
|
|
||||||
width: height
|
|
||||||
name: "../images/media-seek-forward.svg"
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
executeAction("fastForward")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AbstractButton {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
height: Math.min(app.iconSize * 2)
|
|
||||||
ColorIcon {
|
|
||||||
height: parent.height
|
|
||||||
width: height
|
|
||||||
name: "../images/media-skip-forward.svg"
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
executeAction("skipNext")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Item { Layout.fillWidth: true; height: 1 }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user