Merge PR #382: Reduce some warnings from QML
This commit is contained in:
commit
5b1366dc23
@ -42,11 +42,6 @@ QList<State *> States::states()
|
|||||||
return m_states;
|
return m_states;
|
||||||
}
|
}
|
||||||
|
|
||||||
int States::count() const
|
|
||||||
{
|
|
||||||
return m_states.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
State *States::get(int index) const
|
State *States::get(int index) const
|
||||||
{
|
{
|
||||||
return m_states.at(index);
|
return m_states.at(index);
|
||||||
@ -59,7 +54,7 @@ State *States::getState(const QUuid &stateTypeId) const
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int States::rowCount(const QModelIndex &parent) const
|
int States::rowCount(const QModelIndex &parent) const
|
||||||
@ -94,6 +89,7 @@ void States::addState(State *state)
|
|||||||
emit dataChanged(index(idx), index(idx), {ValueRole});
|
emit dataChanged(index(idx), index(idx), {ValueRole});
|
||||||
});
|
});
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> States::roleNames() const
|
QHash<int, QByteArray> States::roleNames() const
|
||||||
|
|||||||
@ -39,6 +39,8 @@
|
|||||||
class States : public QAbstractListModel
|
class States : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum StateRole {
|
enum StateRole {
|
||||||
ValueRole = Qt::DisplayRole,
|
ValueRole = Qt::DisplayRole,
|
||||||
@ -49,7 +51,6 @@ public:
|
|||||||
|
|
||||||
QList<State *> states();
|
QList<State *> states();
|
||||||
|
|
||||||
Q_INVOKABLE int count() const;
|
|
||||||
Q_INVOKABLE State *get(int index) const;
|
Q_INVOKABLE State *get(int index) const;
|
||||||
Q_INVOKABLE State *getState(const QUuid &stateTypeId) const;
|
Q_INVOKABLE State *getState(const QUuid &stateTypeId) const;
|
||||||
|
|
||||||
@ -58,6 +59,9 @@ public:
|
|||||||
|
|
||||||
void addState(State *state);
|
void addState(State *state);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void countChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const;
|
QHash<int, QByteArray> roleNames() const;
|
||||||
|
|
||||||
|
|||||||
@ -158,6 +158,16 @@ ItemDelegate {
|
|||||||
from: root.paramType.minValue
|
from: root.paramType.minValue
|
||||||
to: root.paramType.maxValue
|
to: root.paramType.maxValue
|
||||||
value: root.param.value
|
value: root.param.value
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (root.param.value === undefined) {
|
||||||
|
if (root.paramType.defaultValue !== undefined) {
|
||||||
|
root.param.value = root.paramType.defaultValue
|
||||||
|
} else {
|
||||||
|
root.param.value = root.paramType.minValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stepSize: {
|
stepSize: {
|
||||||
var ret = 1
|
var ret = 1
|
||||||
for (var i = 0; i < decimals; i++) {
|
for (var i = 0; i < decimals; i++) {
|
||||||
|
|||||||
@ -115,6 +115,12 @@ DevicePageBase {
|
|||||||
if (params["id"] === d.pendingVolumeId) {
|
if (params["id"] === d.pendingVolumeId) {
|
||||||
d.pendingVolumeId = -1
|
d.pendingVolumeId = -1
|
||||||
print("volume action finished")
|
print("volume action finished")
|
||||||
|
if (params.params.deviceError !== "DeviceErrorNoError") {
|
||||||
|
print("Error setting volume", params.params.deviceError)
|
||||||
|
d.pendingVolumeValue = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (d.pendingVolumeValue !== volumeState.value) {
|
if (d.pendingVolumeValue !== volumeState.value) {
|
||||||
root.adjustVolume(d.pendingVolumeValue);
|
root.adjustVolume(d.pendingVolumeValue);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -539,7 +539,7 @@ MainPageTile {
|
|||||||
property int currentDevice: 0
|
property int currentDevice: 0
|
||||||
|
|
||||||
property Device device: devicesProxy.get(currentDevice)
|
property Device device: devicesProxy.get(currentDevice)
|
||||||
property DeviceClass deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
property DeviceClass deviceClass: device ? device.deviceClass : null
|
||||||
|
|
||||||
property var shownSensors: findSensors(deviceClass)
|
property var shownSensors: findSensors(deviceClass)
|
||||||
property int currentSensor: 0
|
property int currentSensor: 0
|
||||||
@ -627,7 +627,7 @@ MainPageTile {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: sensorsRoot.shownStateType
|
text: sensorsRoot.shownStateType
|
||||||
? (Math.round(Types.toUiValue(sensorsRoot.device.states.getState(shownStateType.id).value, sensorsRoot.shownStateType.unit) * 100) / 100) + " " + Types.toUiUnit(sensorsRoot.shownStateType.unit)
|
? (Math.round(Types.toUiValue(sensorsRoot.device.states.getState(sensorsRoot.shownStateType.id).value, sensorsRoot.shownStateType.unit) * 100) / 100) + " " + Types.toUiUnit(sensorsRoot.shownStateType.unit)
|
||||||
: ""
|
: ""
|
||||||
// font.pixelSize: app.smallFont
|
// font.pixelSize: app.smallFont
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -637,7 +637,7 @@ MainPageTile {
|
|||||||
Led {
|
Led {
|
||||||
Layout.preferredHeight: app.iconSize * .5
|
Layout.preferredHeight: app.iconSize * .5
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
state: sensorsRoot.shownStateType && sensorsRoot.device.states.getState(sensorsRoot.shownStateType.id).value === true ? "on" : "off"
|
state: visible && sensorsRoot.device.states.getState(sensorsRoot.shownStateType.id).value === true ? "on" : "off"
|
||||||
visible: sensorsRoot.shownStateType && sensorsRoot.shownStateType.type.toLowerCase() === "bool"
|
visible: sensorsRoot.shownStateType && sensorsRoot.shownStateType.type.toLowerCase() === "bool"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user