Make device type combobox work
This commit is contained in:
@ -50,11 +50,13 @@ ColumnLayout {
|
||||
}
|
||||
Label { text: qsTr("DeviceType:") }
|
||||
ComboBox {
|
||||
id: deviceTypeCombobox
|
||||
Layout.fillWidth: true
|
||||
model: deviceTypesModel
|
||||
textRole: "name"
|
||||
valueRole: "id"
|
||||
// TODO make binding for selection
|
||||
currentIndex: deviceTypeCombobox.indexOfValue(listView.currentData.deviceTypeId)
|
||||
onCurrentValueChanged: if (listView.currentData) listView.currentData.deviceTypeId = currentValue; else console.warn('discarded');
|
||||
}
|
||||
Label { text: qsTr("Address:") }
|
||||
SpinBox {
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <QQmlEngine>
|
||||
|
||||
constexpr auto IdRole = Qt::UserRole;
|
||||
constexpr auto LightTypeIdRole = Qt::UserRole + 1;
|
||||
constexpr auto DeviceTypeIdRole = Qt::UserRole + 1;
|
||||
constexpr auto AddressRole = Qt::UserRole + 2;
|
||||
constexpr auto PositionRole = Qt::UserRole + 3;
|
||||
|
||||
@ -33,7 +33,7 @@ int DevicesModel::rowCount(const QModelIndex &parent) const
|
||||
if (!m_controller)
|
||||
return 0;
|
||||
|
||||
return m_controller->lightProject().lights.size();
|
||||
return m_controller->lightProject().devices.size();
|
||||
}
|
||||
|
||||
QVariant DevicesModel::data(const QModelIndex &index, int role) const
|
||||
@ -50,8 +50,8 @@ QVariant DevicesModel::data(const QModelIndex &index, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lights = m_controller->lightProject().lights;
|
||||
if (index.row() < 0 || index.row() >= lights.size())
|
||||
const auto &devices = m_controller->lightProject().devices;
|
||||
if (index.row() < 0 || index.row() >= devices.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
@ -63,16 +63,16 @@ QVariant DevicesModel::data(const QModelIndex &index, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &light = lights.at(index.row());
|
||||
const auto &device = devices.at(index.row());
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole: return light.name;
|
||||
case IdRole: return light.id;
|
||||
case LightTypeIdRole: return light.lightTypeId;
|
||||
case AddressRole: return light.address;
|
||||
case PositionRole: return light.position;
|
||||
case Qt::EditRole: return device.name;
|
||||
case IdRole: return device.id;
|
||||
case DeviceTypeIdRole: return device.deviceTypeId;
|
||||
case AddressRole: return device.address;
|
||||
case PositionRole: return device.position;
|
||||
}
|
||||
|
||||
return {};
|
||||
@ -92,8 +92,8 @@ QMap<int, QVariant> DevicesModel::itemData(const QModelIndex &index) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lights = m_controller->lightProject().lights;
|
||||
if (index.row() < 0 || index.row() >= lights.size())
|
||||
const auto &devices = m_controller->lightProject().devices;
|
||||
if (index.row() < 0 || index.row() >= devices.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
@ -105,14 +105,13 @@ QMap<int, QVariant> DevicesModel::itemData(const QModelIndex &index) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &light = lights.at(index.row());
|
||||
|
||||
const auto &device = devices.at(index.row());
|
||||
return {
|
||||
{ Qt::DisplayRole, light.name },
|
||||
{ IdRole, light.id },
|
||||
{ LightTypeIdRole, light.lightTypeId },
|
||||
{ AddressRole, light.address },
|
||||
{ PositionRole, light.position }
|
||||
{ Qt::DisplayRole, device.name },
|
||||
{ IdRole, device.id },
|
||||
{ DeviceTypeIdRole, device.deviceTypeId },
|
||||
{ AddressRole, device.address },
|
||||
{ PositionRole, device.position }
|
||||
};
|
||||
}
|
||||
|
||||
@ -121,7 +120,7 @@ QHash<int, QByteArray> DevicesModel::roleNames() const
|
||||
return {
|
||||
{ Qt::DisplayRole, "name" },
|
||||
{ IdRole, "id" },
|
||||
{ LightTypeIdRole, "lightTypeId" },
|
||||
{ DeviceTypeIdRole, "deviceTypeId" },
|
||||
{ AddressRole, "address" },
|
||||
{ PositionRole, "position" }
|
||||
};
|
||||
@ -141,8 +140,8 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &lights = m_controller->lightProject().lights;
|
||||
if (index.row() < 0 || index.row() >= lights.size())
|
||||
auto &devices = m_controller->lightProject().devices;
|
||||
if (index.row() < 0 || index.row() >= devices.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
@ -154,7 +153,7 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &light = lights.at(index.row());
|
||||
auto &device = devices.at(index.row());
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
@ -164,7 +163,7 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||
return false;
|
||||
}
|
||||
light.name = value.toString();
|
||||
device.name = value.toString();
|
||||
emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole });
|
||||
return true;
|
||||
case IdRole:
|
||||
@ -173,17 +172,17 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||
return false;
|
||||
}
|
||||
light.id = value.toInt();
|
||||
device.id = value.toInt();
|
||||
emit dataChanged(index, index, { IdRole });
|
||||
return true;
|
||||
case LightTypeIdRole:
|
||||
case DeviceTypeIdRole:
|
||||
if (value.userType() != QMetaType::Int)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||
return false;
|
||||
}
|
||||
light.lightTypeId = value.toInt();
|
||||
emit dataChanged(index, index, { LightTypeIdRole });
|
||||
device.deviceTypeId = value.toInt();
|
||||
emit dataChanged(index, index, { DeviceTypeIdRole });
|
||||
return true;
|
||||
case AddressRole:
|
||||
if (value.userType() != QMetaType::Int)
|
||||
@ -191,7 +190,7 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||
return false;
|
||||
}
|
||||
light.address = value.toInt();
|
||||
device.address = value.toInt();
|
||||
emit dataChanged(index, index, { AddressRole });
|
||||
return true;
|
||||
case PositionRole:
|
||||
@ -200,7 +199,7 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||
return false;
|
||||
}
|
||||
light.position = value.value<QVector3D>();
|
||||
device.position = value.value<QVector3D>();
|
||||
emit dataChanged(index, index, { PositionRole });
|
||||
return true;
|
||||
}
|
||||
@ -222,7 +221,7 @@ bool DevicesModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &lights = m_controller->lightProject().lights;
|
||||
auto &devices = m_controller->lightProject().devices;
|
||||
|
||||
if (row < 0)
|
||||
{
|
||||
@ -230,19 +229,19 @@ bool DevicesModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (row > lights.size())
|
||||
if (row > devices.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto max_iter = std::max_element(std::cbegin(lights), std::cend(lights), [](const auto &l, const auto &r){ return l.id < r.id; });
|
||||
auto id = max_iter != std::cend(lights) ? max_iter->id + 1 : 0;
|
||||
auto max_iter = std::max_element(std::cbegin(devices), std::cend(devices), [](const auto &l, const auto &r){ return l.id < r.id; });
|
||||
auto id = max_iter != std::cend(devices) ? max_iter->id + 1 : 0;
|
||||
|
||||
beginInsertRows({}, row, row+count-1);
|
||||
auto iter = std::begin(lights) + row;
|
||||
auto iter = std::begin(devices) + row;
|
||||
for (; count > 0; count--)
|
||||
iter = lights.insert(iter, LightConfig{ .id=id++, .name="<neu>", .lightTypeId=0, .address=0, .position={} }) + 1;
|
||||
iter = devices.insert(iter, LightConfig{ .id=id++, .name="<neu>", .deviceTypeId=0, .address=0, .position={} }) + 1;
|
||||
endInsertRows();
|
||||
|
||||
return true;
|
||||
@ -262,7 +261,7 @@ bool DevicesModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &lights = m_controller->lightProject().lights;
|
||||
auto &devices = m_controller->lightProject().devices;
|
||||
|
||||
if (row < 0)
|
||||
{
|
||||
@ -270,22 +269,22 @@ bool DevicesModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (row >= lights.size())
|
||||
if (row >= devices.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (row + count > lights.size())
|
||||
if (row + count > devices.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
||||
beginRemoveRows({}, row, row+count-1);
|
||||
auto begin = std::begin(lights) + row;
|
||||
auto begin = std::begin(devices) + row;
|
||||
auto end = begin + count;
|
||||
lights.erase(begin, end);
|
||||
devices.erase(begin, end);
|
||||
endRemoveRows();
|
||||
|
||||
return true;
|
||||
|
@ -42,14 +42,14 @@ int DeviceTypeRegistersModel::rowCount(const QModelIndex &parent) const
|
||||
if (m_deviceTypeId == -1)
|
||||
return 0;
|
||||
|
||||
auto lightType = m_controller->lightProject().lightTypes.findById(m_deviceTypeId);
|
||||
if (!lightType)
|
||||
auto deviceType = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
||||
if (!deviceType)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return lightType->registers.size();
|
||||
return deviceType->registers.size();
|
||||
}
|
||||
|
||||
QVariant DeviceTypeRegistersModel::data(const QModelIndex &index, int role) const
|
||||
@ -72,14 +72,14 @@ QVariant DeviceTypeRegistersModel::data(const QModelIndex &index, int role) cons
|
||||
return {};
|
||||
}
|
||||
|
||||
auto lightType = m_controller->lightProject().lightTypes.findById(m_deviceTypeId);
|
||||
if (!lightType)
|
||||
auto deviceType = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
||||
if (!deviceType)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (index.row() < 0 || index.row() >= lightType->registers.size())
|
||||
if (index.row() < 0 || index.row() >= deviceType->registers.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
@ -91,16 +91,16 @@ QVariant DeviceTypeRegistersModel::data(const QModelIndex &index, int role) cons
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lightTypeRegister = lightType->registers.at(index.row());
|
||||
const auto &deviceTypeRegister = deviceType->registers.at(index.row());
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
return QMetaEnum::fromType<LightTypeRegisterType>().valueToKey(std::to_underlying(lightTypeRegister.type));
|
||||
return QMetaEnum::fromType<DeviceTypeRegisterType>().valueToKey(std::to_underlying(deviceTypeRegister.type));
|
||||
}
|
||||
case Qt::EditRole:
|
||||
return QVariant::fromValue(lightTypeRegister.type);
|
||||
return QVariant::fromValue(deviceTypeRegister.type);
|
||||
}
|
||||
|
||||
return {};
|
||||
@ -126,14 +126,14 @@ QMap<int, QVariant> DeviceTypeRegistersModel::itemData(const QModelIndex &index)
|
||||
return {};
|
||||
}
|
||||
|
||||
auto lightType = m_controller->lightProject().lightTypes.findById(m_deviceTypeId);
|
||||
if (!lightType)
|
||||
auto deviceType = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
||||
if (!deviceType)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (index.row() < 0 || index.row() >= lightType->registers.size())
|
||||
if (index.row() < 0 || index.row() >= deviceType->registers.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
@ -145,11 +145,11 @@ QMap<int, QVariant> DeviceTypeRegistersModel::itemData(const QModelIndex &index)
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lightTypeRegister = lightType->registers.at(index.row());
|
||||
const auto &deviceTypeRegister = deviceType->registers.at(index.row());
|
||||
|
||||
return {
|
||||
{ Qt::DisplayRole, QMetaEnum::fromType<LightTypeRegisterType>().valueToKey(std::to_underlying(lightTypeRegister.type)) },
|
||||
{ Qt::EditRole, QVariant::fromValue(lightTypeRegister.type) }
|
||||
{ Qt::DisplayRole, QMetaEnum::fromType<DeviceTypeRegisterType>().valueToKey(std::to_underlying(deviceTypeRegister.type)) },
|
||||
{ Qt::EditRole, QVariant::fromValue(deviceTypeRegister.type) }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ int DeviceTypesModel::rowCount(const QModelIndex &parent) const
|
||||
if (!m_controller)
|
||||
return 0;
|
||||
|
||||
return m_controller->lightProject().lightTypes.size();
|
||||
return m_controller->lightProject().deviceTypes.size();
|
||||
}
|
||||
|
||||
QVariant DeviceTypesModel::data(const QModelIndex &index, int role) const
|
||||
@ -45,9 +45,9 @@ QVariant DeviceTypesModel::data(const QModelIndex &index, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lightTypes = m_controller->lightProject().lightTypes;
|
||||
const auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||
|
||||
if (index.row() < 0 || index.row() >= lightTypes.size())
|
||||
if (index.row() < 0 || index.row() >= deviceTypes.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
@ -59,13 +59,13 @@ QVariant DeviceTypesModel::data(const QModelIndex &index, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lightType = lightTypes.at(index.row());
|
||||
const auto &deviceType = deviceTypes.at(index.row());
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole: return lightType.name;
|
||||
case IdRole: return lightType.id;
|
||||
case Qt::EditRole: return deviceType.name;
|
||||
case IdRole: return deviceType.id;
|
||||
}
|
||||
|
||||
return {};
|
||||
@ -85,9 +85,9 @@ QMap<int, QVariant> DeviceTypesModel::itemData(const QModelIndex &index) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lightTypes = m_controller->lightProject().lightTypes;
|
||||
const auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||
|
||||
if (index.row() < 0 || index.row() >= lightTypes.size())
|
||||
if (index.row() < 0 || index.row() >= deviceTypes.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
@ -99,11 +99,11 @@ QMap<int, QVariant> DeviceTypesModel::itemData(const QModelIndex &index) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lightType = lightTypes.at(index.row());
|
||||
const auto &deviceType = deviceTypes.at(index.row());
|
||||
|
||||
return {
|
||||
{ Qt::DisplayRole, lightType.name },
|
||||
{ IdRole, lightType.id }
|
||||
{ Qt::DisplayRole, deviceType.name },
|
||||
{ IdRole, deviceType.id }
|
||||
};
|
||||
}
|
||||
|
||||
@ -129,8 +129,8 @@ bool DeviceTypesModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &lightTypes = m_controller->lightProject().lightTypes;
|
||||
if (index.row() < 0 || index.row() >= lightTypes.size())
|
||||
auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||
if (index.row() < 0 || index.row() >= deviceTypes.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
@ -142,7 +142,7 @@ bool DeviceTypesModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &lightType = lightTypes.at(index.row());
|
||||
auto &deviceType = deviceTypes.at(index.row());
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
@ -152,7 +152,7 @@ bool DeviceTypesModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||
return false;
|
||||
}
|
||||
lightType.name = value.toString();
|
||||
deviceType.name = value.toString();
|
||||
emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole });
|
||||
return true;
|
||||
case IdRole:
|
||||
@ -161,7 +161,7 @@ bool DeviceTypesModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||
return false;
|
||||
}
|
||||
lightType.id = value.toInt();
|
||||
deviceType.id = value.toInt();
|
||||
emit dataChanged(index, index, { IdRole });
|
||||
return true;
|
||||
}
|
||||
@ -183,7 +183,7 @@ bool DeviceTypesModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &lightTypes = m_controller->lightProject().lightTypes;
|
||||
auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||
|
||||
if (row < 0)
|
||||
{
|
||||
@ -191,19 +191,19 @@ bool DeviceTypesModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (row > lightTypes.size())
|
||||
if (row > deviceTypes.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto max_iter = std::max_element(std::cbegin(lightTypes), std::cend(lightTypes), [](const auto &l, const auto &r){ return l.id < r.id; });
|
||||
auto id = max_iter != std::cend(lightTypes) ? max_iter->id + 1 : 0;
|
||||
auto max_iter = std::max_element(std::cbegin(deviceTypes), std::cend(deviceTypes), [](const auto &l, const auto &r){ return l.id < r.id; });
|
||||
auto id = max_iter != std::cend(deviceTypes) ? max_iter->id + 1 : 0;
|
||||
|
||||
beginInsertRows({}, row, row+count-1);
|
||||
auto iter = std::begin(lightTypes) + row;
|
||||
auto iter = std::begin(deviceTypes) + row;
|
||||
for (; count > 0; count--)
|
||||
iter = lightTypes.insert(iter, LightTypeConfig{ .id=id++, .name="<neu>" }) + 1;
|
||||
iter = deviceTypes.insert(iter, DeviceTypeConfig{ .id=id++, .name="<neu>" }) + 1;
|
||||
endInsertRows();
|
||||
|
||||
return true;
|
||||
@ -223,7 +223,7 @@ bool DeviceTypesModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &lightTypes = m_controller->lightProject().lightTypes;
|
||||
auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||
|
||||
if (row < 0)
|
||||
{
|
||||
@ -231,22 +231,22 @@ bool DeviceTypesModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (row >= lightTypes.size())
|
||||
if (row >= deviceTypes.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (row + count > lightTypes.size())
|
||||
if (row + count > deviceTypes.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
||||
beginRemoveRows({}, row, row+count-1);
|
||||
auto begin = std::begin(lightTypes) + row;
|
||||
auto begin = std::begin(deviceTypes) + row;
|
||||
auto end = begin + count;
|
||||
lightTypes.erase(begin, end);
|
||||
deviceTypes.erase(begin, end);
|
||||
endRemoveRows();
|
||||
|
||||
return true;
|
||||
|
@ -11,7 +11,7 @@ DmxController::DmxController(QObject *parent) :
|
||||
m_lastInfo{QDateTime::currentDateTime()},
|
||||
m_counter{},
|
||||
m_lightProject {
|
||||
.lightTypes {
|
||||
.deviceTypes {
|
||||
{
|
||||
.id=0,
|
||||
.name="Stairville MH-X50+"
|
||||
@ -20,13 +20,13 @@ DmxController::DmxController(QObject *parent) :
|
||||
.id=1,
|
||||
.name="RGBW Strahler",
|
||||
.registers {
|
||||
LightTypeRegisterConfig { .type = LightTypeRegisterType::Dimmer },
|
||||
LightTypeRegisterConfig { .type = LightTypeRegisterType::Red },
|
||||
LightTypeRegisterConfig { .type = LightTypeRegisterType::Green },
|
||||
LightTypeRegisterConfig { .type = LightTypeRegisterType::Blue },
|
||||
LightTypeRegisterConfig { .type = LightTypeRegisterType::White },
|
||||
LightTypeRegisterConfig { .type = LightTypeRegisterType::Strobo },
|
||||
LightTypeRegisterConfig { .type = LightTypeRegisterType::Dummy }
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Dimmer },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Red },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Green },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Blue },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::White },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Strobo },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Dummy }
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -38,18 +38,18 @@ DmxController::DmxController(QObject *parent) :
|
||||
.name="Nebelmaschine"
|
||||
}
|
||||
},
|
||||
.lights {
|
||||
{ .id=0, .name="Lampe 1", .lightTypeId=1, .address=32, .position{1,0,0} },
|
||||
{ .id=1, .name="Lampe 2", .lightTypeId=1, .address=0, .position{2,0,0} },
|
||||
{ .id=2, .name="Lampe 3", .lightTypeId=1, .address=7, .position{3,0,0} },
|
||||
{ .id=3, .name="Lampe 4", .lightTypeId=1, .address=14 },
|
||||
{ .id=4, .name="Moving Head 1", .lightTypeId=0, .address=40 },
|
||||
{ .id=5, .name="Moving Head 2", .lightTypeId=0, .address=43 },
|
||||
{ .id=6, .name="Moving Head 3", .lightTypeId=0, .address=46 },
|
||||
{ .id=7, .name="Moving Head 4", .lightTypeId=0, .address=49 },
|
||||
{ .id=8, .name="Test 1", .lightTypeId=2, .address=70 },
|
||||
{ .id=9, .name="Test 2", .lightTypeId=2, .address=72 },
|
||||
{ .id=10, .name="Nebelmaschine", .lightTypeId=3, .address=80 }
|
||||
.devices {
|
||||
{ .id=0, .name="Lampe 1", .deviceTypeId=1, .address=32, .position{1,0,0} },
|
||||
{ .id=1, .name="Lampe 2", .deviceTypeId=1, .address=0, .position{2,0,0} },
|
||||
{ .id=2, .name="Lampe 3", .deviceTypeId=1, .address=7, .position{3,0,0} },
|
||||
{ .id=3, .name="Lampe 4", .deviceTypeId=1, .address=14 },
|
||||
{ .id=4, .name="Moving Head 1", .deviceTypeId=0, .address=40 },
|
||||
{ .id=5, .name="Moving Head 2", .deviceTypeId=0, .address=43 },
|
||||
{ .id=6, .name="Moving Head 3", .deviceTypeId=0, .address=46 },
|
||||
{ .id=7, .name="Moving Head 4", .deviceTypeId=0, .address=49 },
|
||||
{ .id=8, .name="Test 1", .deviceTypeId=2, .address=70 },
|
||||
{ .id=9, .name="Test 2", .deviceTypeId=2, .address=72 },
|
||||
{ .id=10, .name="Nebelmaschine", .deviceTypeId=3, .address=80 }
|
||||
}
|
||||
}
|
||||
{
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace hilfe {
|
||||
Q_NAMESPACE
|
||||
enum class LightTypeRegisterType
|
||||
enum class DeviceTypeRegisterType
|
||||
{
|
||||
Dummy,
|
||||
Dimmer,
|
||||
@ -21,43 +21,43 @@ enum class LightTypeRegisterType
|
||||
Strobo,
|
||||
Shutter
|
||||
};
|
||||
Q_ENUM_NS(LightTypeRegisterType)
|
||||
Q_ENUM_NS(DeviceTypeRegisterType)
|
||||
} // namespace hilfe
|
||||
|
||||
Q_DECLARE_METATYPE(hilfe::LightTypeRegisterType)
|
||||
Q_DECLARE_METATYPE(hilfe::DeviceTypeRegisterType)
|
||||
|
||||
using LightTypeRegisterType = hilfe::LightTypeRegisterType;
|
||||
using DeviceTypeRegisterType = hilfe::DeviceTypeRegisterType;
|
||||
|
||||
struct LightTypeRegisterConfig
|
||||
struct DeviceTypeRegisterConfig
|
||||
{
|
||||
LightTypeRegisterType type;
|
||||
DeviceTypeRegisterType type;
|
||||
};
|
||||
|
||||
struct LightTypeConfig
|
||||
struct DeviceTypeConfig
|
||||
{
|
||||
int id;
|
||||
QString name;
|
||||
std::vector<LightTypeRegisterConfig> registers;
|
||||
std::vector<DeviceTypeRegisterConfig> registers;
|
||||
};
|
||||
|
||||
class LightTypesContainer : public std::vector<LightTypeConfig>
|
||||
class DeviceTypesContainer : public std::vector<DeviceTypeConfig>
|
||||
{
|
||||
using base_t = std::vector<LightTypeConfig>;
|
||||
using base_t = std::vector<DeviceTypeConfig>;
|
||||
|
||||
public:
|
||||
using base_t::base_t;
|
||||
|
||||
LightTypeConfig *findById(int id)
|
||||
DeviceTypeConfig *findById(int id)
|
||||
{
|
||||
auto iter = std::find_if(std::begin(*this), std::end(*this),
|
||||
[&id](const LightTypeConfig &lightType){ return lightType.id == id; });
|
||||
[&id](const DeviceTypeConfig &deviceType){ return deviceType.id == id; });
|
||||
return iter != std::end(*this) ? &*iter : nullptr;
|
||||
}
|
||||
|
||||
const LightTypeConfig *findById(int id) const
|
||||
const DeviceTypeConfig *findById(int id) const
|
||||
{
|
||||
auto iter = std::find_if(std::begin(*this), std::end(*this),
|
||||
[&id](const LightTypeConfig &lightType){ return lightType.id == id; });
|
||||
[&id](const DeviceTypeConfig &deviceType){ return deviceType.id == id; });
|
||||
return iter != std::end(*this) ? &*iter : nullptr;
|
||||
}
|
||||
};
|
||||
@ -66,13 +66,13 @@ struct LightConfig
|
||||
{
|
||||
int id;
|
||||
QString name;
|
||||
int lightTypeId;
|
||||
int deviceTypeId;
|
||||
int address;
|
||||
QVector3D position;
|
||||
};
|
||||
|
||||
struct LightProject
|
||||
{
|
||||
LightTypesContainer lightTypes;
|
||||
std::vector<LightConfig> lights;
|
||||
DeviceTypesContainer deviceTypes;
|
||||
std::vector<LightConfig> devices;
|
||||
};
|
||||
|
Reference in New Issue
Block a user