Implemented adding of new registers to device types
This commit is contained in:
@@ -27,6 +27,7 @@ ApplicationWindow {
|
|||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
id: deviceTypeRegisterTypesModel
|
id: deviceTypeRegisterTypesModel
|
||||||
|
ListElement { text: qsTr('Dummy'); value: DeviceTypeRegisterType.Dummy }
|
||||||
ListElement { text: qsTr('Dimmer'); value: DeviceTypeRegisterType.Dimmer }
|
ListElement { text: qsTr('Dimmer'); value: DeviceTypeRegisterType.Dimmer }
|
||||||
ListElement { text: qsTr('Red'); value: DeviceTypeRegisterType.Red }
|
ListElement { text: qsTr('Red'); value: DeviceTypeRegisterType.Red }
|
||||||
ListElement { text: qsTr('Green'); value: DeviceTypeRegisterType.Green }
|
ListElement { text: qsTr('Green'); value: DeviceTypeRegisterType.Green }
|
||||||
|
@@ -31,6 +31,7 @@ Pane {
|
|||||||
|
|
||||||
model: deviceTypeRegistersModel
|
model: deviceTypeRegistersModel
|
||||||
|
|
||||||
|
onAddClicked: (index) => deviceTypeRegistersModel.insertRow(index < 0 ? 0 : index + 1);
|
||||||
onRemoveClicked: (index) => deviceTypeRegistersModel.removeRow(index)
|
onRemoveClicked: (index) => deviceTypeRegistersModel.removeRow(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -215,8 +215,60 @@ bool DeviceTypeRegistersModel::setData(const QModelIndex &index, const QVariant
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DeviceTypeRegistersModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
if (parent.isValid())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_controller)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_deviceTypeId == -1)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto deviceTypePtr = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
||||||
|
if (!deviceTypePtr)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &deviceType = *deviceTypePtr;
|
||||||
|
|
||||||
|
if (row < 0)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ®isters = deviceType.registers;
|
||||||
|
|
||||||
|
beginInsertRows({}, row, row+count-1);
|
||||||
|
auto iter = std::begin(registers) + row;
|
||||||
|
for (; count > 0; count--)
|
||||||
|
iter = registers.insert(iter, DeviceTypeRegisterConfig{ .type = DeviceTypeRegisterType::Dummy }) + 1;
|
||||||
|
endInsertRows();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool DeviceTypeRegistersModel::removeRows(int row, int count, const QModelIndex &parent)
|
bool DeviceTypeRegistersModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
|
if (parent.isValid())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_controller)
|
if (!m_controller)
|
||||||
{
|
{
|
||||||
qWarning() << "hilfe" << __LINE__;
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
@@ -26,6 +26,7 @@ public:
|
|||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
|
bool insertRows(int row, int count, const QModelIndex &parent) override;
|
||||||
bool removeRows(int row, int count, const QModelIndex &parent) override;
|
bool removeRows(int row, int count, const QModelIndex &parent) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
4
main.cpp
4
main.cpp
@@ -3,8 +3,6 @@
|
|||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#include "dmxcontroller.h"
|
#include "dmxcontroller.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -24,8 +22,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QGuiApplication app{argc, argv};
|
QGuiApplication app{argc, argv};
|
||||||
|
|
||||||
qDebug() << QDir{":/lightcontrol"}.entryInfoList();
|
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addVersionOption();
|
parser.addVersionOption();
|
||||||
|
Reference in New Issue
Block a user