Register groups model improvements and more default registers

This commit is contained in:
2023-02-19 22:41:26 +01:00
parent 2461e00c73
commit 657437452b
9 changed files with 174 additions and 40 deletions

View File

@ -23,11 +23,11 @@ qt_add_executable(applightcontrol
qt_add_qml_module(applightcontrol
URI lightcontrol
VERSION 1.0
RESOURCES
icons/movinghead.png
icons/nebelmaschine.png
icons/rgbstrahler.png
VERSION 1.0
QML_FILES
main.qml
HomePage.qml

View File

@ -3,12 +3,29 @@ import QtQuick
import lightcontrol
ListModel {
ListElement { text: qsTr('Dummy'); value: DeviceTypeRegisterType.Dummy }
ListElement { text: qsTr('Dimmer'); value: DeviceTypeRegisterType.Dimmer }
ListElement { text: qsTr('Red'); value: DeviceTypeRegisterType.Red }
ListElement { text: qsTr('Green'); value: DeviceTypeRegisterType.Green }
ListElement { text: qsTr('Blue'); value: DeviceTypeRegisterType.Blue }
ListElement { text: qsTr('White'); value: DeviceTypeRegisterType.White }
ListElement { text: qsTr('Strobo'); value: DeviceTypeRegisterType.Strobo }
ListElement { text: qsTr('Shutter'); value: DeviceTypeRegisterType.Shutter }
ListElement { text: qsTr('Dummy'); value: DeviceTypeRegisterType.Dummy }
ListElement { text: qsTr('Dimmer'); value: DeviceTypeRegisterType.Dimmer }
ListElement { text: qsTr('Red'); value: DeviceTypeRegisterType.Red }
ListElement { text: qsTr('Green'); value: DeviceTypeRegisterType.Green }
ListElement { text: qsTr('Blue'); value: DeviceTypeRegisterType.Blue }
ListElement { text: qsTr('White'); value: DeviceTypeRegisterType.White }
ListElement { text: qsTr('Shutter'); value: DeviceTypeRegisterType.Shutter }
ListElement { text: qsTr('Pan'); value: DeviceTypeRegisterType.Pan }
ListElement { text: qsTr('PanFine'); value: DeviceTypeRegisterType.PanFine }
ListElement { text: qsTr('Tilt'); value: DeviceTypeRegisterType.Tilt }
ListElement { text: qsTr('TiltFine'); value: DeviceTypeRegisterType.TiltFine }
ListElement { text: qsTr('Color'); value: DeviceTypeRegisterType.Color }
ListElement { text: qsTr('Cyan'); value: DeviceTypeRegisterType.Cyan }
ListElement { text: qsTr('Magenta'); value: DeviceTypeRegisterType.Magenta }
ListElement { text: qsTr('Yellow'); value: DeviceTypeRegisterType.Yellow }
ListElement { text: qsTr('Gobo'); value: DeviceTypeRegisterType.Gobo }
ListElement { text: qsTr('Rotation'); value: DeviceTypeRegisterType.Rotation }
ListElement { text: qsTr('Prism'); value: DeviceTypeRegisterType.Prism }
ListElement { text: qsTr('Frost'); value: DeviceTypeRegisterType.Frost }
ListElement { text: qsTr('Focus'); value: DeviceTypeRegisterType.Focus }
ListElement { text: qsTr('Speed'); value: DeviceTypeRegisterType.Speed }
ListElement { text: qsTr('Iris'); value: DeviceTypeRegisterType.Iris }
ListElement { text: qsTr('Zoom'); value: DeviceTypeRegisterType.Zoom }
ListElement { text: qsTr('Extra1'); value: DeviceTypeRegisterType.Extra1 }
ListElement { text: qsTr('Extra2'); value: DeviceTypeRegisterType.Extra2 }
}

View File

@ -2,7 +2,7 @@ import QtQuick
import QtQuick.Controls.Material
import QtQuick.Layouts
import lightcontrol
import lightcontrol 1.0
Pane {
property alias deviceTypeId: model.deviceTypeId

View File

@ -444,4 +444,3 @@ void registrierDenShit()
}
}
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)

View File

@ -15,7 +15,23 @@ DmxController::DmxController(QObject *parent) :
{
.id=0,
.name="Stairville MH-X50+",
.iconName="movinghead"
.iconName="movinghead",
.registers {
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Pan },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Tilt },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::PanFine },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::TiltFine },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Speed },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Color },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Shutter },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Dimmer },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Gobo },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Rotation },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Extra1 },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Extra2 },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Prism },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Focus }
}
},
{
.id=1,
@ -27,8 +43,8 @@ DmxController::DmxController(QObject *parent) :
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Green },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Blue },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::White },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Strobo },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Dummy }
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Shutter },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Extra1 }
}
},
{
@ -59,8 +75,8 @@ DmxController::DmxController(QObject *parent) :
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Green },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Blue },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::White },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Dummy },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Strobo }
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Extra1 },
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Shutter }
}
}
},
@ -92,19 +108,19 @@ DmxController::DmxController(QObject *parent) :
{ .id=2, .name="Alle Grünen" },
{ .id=3, .name="Alle Blauen" },
{ .id=4, .name="Alle Weißen" },
{ .id=5, .name="Alle Strobo" },
{ .id=5, .name="Alle Shutter" },
{ .id=6, .name="2n Dimmmer" },
{ .id=7, .name="2n Roten" },
{ .id=8, .name="2n Grünen" },
{ .id=9, .name="2n Blauen" },
{ .id=10, .name="2n Weißen" },
{ .id=11, .name="2n Strobo" },
{ .id=11, .name="2n Shutter" },
{ .id=12, .name="2n+1 Dimmmer" },
{ .id=13, .name="2n+1 Roten" },
{ .id=14, .name="2n+1 Grünen" },
{ .id=15, .name="2n+1 Blauen" },
{ .id=16, .name="2n+1 Weißen" },
{ .id=17, .name="2n+1 Strobo" },
{ .id=17, .name="2n+1 Shutter" },
}
}
{
@ -152,7 +168,6 @@ bool DmxController::start()
void DmxController::setChannel(int channel, int value)
{
//qDebug() << channel << value;
Q_ASSERT(channel >= 0 && channel < std::size(buf));
buf[channel] = value;
}

View File

@ -32,19 +32,23 @@ signals:
void deviceTypeInserted(int first, int last);
void deviceTypeRemoved(int first, int last);
void deviceTypeNameChanged(int index, const QString &name);
void deviceTypeIconNameChanged(int index, const QString &iconName);
void deviceTypeNameChanged(int row, const QString &name);
void deviceTypeIconNameChanged(int row, const QString &iconName);
void deviceTypeRegisterInserted(const DeviceTypeConfig &deviceType, int first, int last);
void deviceTypeRegisterRemoved(const DeviceTypeConfig &deviceType, int first, int last);
void deviceTypeRegisterTypeChanged(const DeviceTypeConfig &deviceType, int index, DeviceTypeRegisterType type);
void deviceTypeRegisterTypeChanged(const DeviceTypeConfig &deviceType, int row, DeviceTypeRegisterType type);
void deviceInserted(int first, int last);
void deviceRemoved(int first, int last);
void deviceNameChanged(int index, const QString &name);
void deviceDeviceTypeIdChanged(int index, int deviceTypeId);
void deviceAddressChanged(int index, int address);
void devicePositionChanged(int index, const QVector3D &position);
void deviceNameChanged(int row, const QString &name);
void deviceDeviceTypeIdChanged(int row, int deviceTypeId);
void deviceAddressChanged(int row, int address);
void devicePositionChanged(int row, const QVector3D &position);
void registerGroupInserted(int first, int last);
void registerGroupRemoved(int first, int last);
void registerGroupNameChanged(int row, const QString &name);
protected:
friend class DmxControllerThread;

View File

@ -18,8 +18,25 @@ enum class DeviceTypeRegisterType
Green,
Blue,
White,
Strobo,
Shutter
Shutter,
Pan,
PanFine,
Tilt,
TiltFine,
Color,
Cyan,
Magenta,
Yellow,
Gobo,
Rotation,
Prism,
Frost,
Focus,
Speed,
Iris,
Zoom,
Extra1,
Extra2
};
Q_ENUM_NS(DeviceTypeRegisterType)
} // namespace hilfe

View File

@ -14,7 +14,29 @@ void RegisterGroupsModel::setController(DmxController *controller)
return;
beginResetModel();
if (m_controller)
{
disconnect(m_controller, &DmxController::registerGroupInserted,
this, &RegisterGroupsModel::otherRegisterGroupInserted);
disconnect(m_controller, &DmxController::registerGroupRemoved,
this, &RegisterGroupsModel::otherRegisterGroupRemoved);
disconnect(m_controller, &DmxController::registerGroupNameChanged,
this, &RegisterGroupsModel::otherRegisterGroupNameChanged);
}
m_controller = controller;
if (m_controller)
{
connect(m_controller, &DmxController::registerGroupInserted,
this, &RegisterGroupsModel::otherRegisterGroupInserted);
connect(m_controller, &DmxController::registerGroupRemoved,
this, &RegisterGroupsModel::otherRegisterGroupRemoved);
connect(m_controller, &DmxController::registerGroupNameChanged,
this, &RegisterGroupsModel::otherRegisterGroupNameChanged);
}
endResetModel();
emit controllerChanged(m_controller);
}
@ -157,6 +179,13 @@ bool RegisterGroupsModel::setData(const QModelIndex &index, const QVariant &valu
}
registerGroup.name = value.toString();
emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole });
disconnect(m_controller, &DmxController::registerGroupNameChanged,
this, &RegisterGroupsModel::otherRegisterGroupNameChanged);
emit m_controller->registerGroupNameChanged(index.row(), registerGroup.name);
connect(m_controller, &DmxController::registerGroupNameChanged,
this, &RegisterGroupsModel::otherRegisterGroupNameChanged);
return true;
case IdRole:
if (value.userType() != QMetaType::Int)
@ -187,7 +216,7 @@ bool RegisterGroupsModel::insertRows(int row, int count, const QModelIndex &pare
return false;
}
auto &devices = m_controller->lightProject().devices;
auto &registerGroups = m_controller->lightProject().registerGroups;
if (row < 0)
{
@ -195,21 +224,27 @@ bool RegisterGroupsModel::insertRows(int row, int count, const QModelIndex &pare
return false;
}
if (row > devices.size())
if (row > registerGroups.size())
{
qWarning() << "hilfe" << __LINE__;
return false;
}
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;
auto max_iter = std::max_element(std::cbegin(registerGroups), std::cend(registerGroups), [](const auto &l, const auto &r){ return l.id < r.id; });
auto id = max_iter != std::cend(registerGroups) ? max_iter->id + 1 : 0;
beginInsertRows({}, row, row+count-1);
auto iter = std::begin(devices) + row;
auto iter = std::begin(registerGroups) + row;
for (auto i = 0; i < count; i++)
iter = devices.insert(iter, LightConfig{ .id=id++, .name="<neu>", .deviceTypeId=0, .address=0, .position={} }) + 1;
iter = registerGroups.insert(iter, RegisterGroupConfig{ .id=id++, .name="<neu>" }) + 1;
endInsertRows();
disconnect(m_controller, &DmxController::registerGroupInserted,
this, &RegisterGroupsModel::otherRegisterGroupInserted);
emit m_controller->registerGroupInserted(row, row+count-1);
connect(m_controller, &DmxController::registerGroupInserted,
this, &RegisterGroupsModel::otherRegisterGroupInserted);
return true;
}
@ -227,7 +262,7 @@ bool RegisterGroupsModel::removeRows(int row, int count, const QModelIndex &pare
return false;
}
auto &devices = m_controller->lightProject().devices;
auto &registerGroups = m_controller->lightProject().registerGroups;
if (row < 0)
{
@ -235,27 +270,69 @@ bool RegisterGroupsModel::removeRows(int row, int count, const QModelIndex &pare
return false;
}
if (row >= devices.size())
if (row >= registerGroups.size())
{
qWarning() << "hilfe" << __LINE__;
return false;
}
if (row + count > devices.size())
if (row + count > registerGroups.size())
{
qWarning() << "hilfe" << __LINE__;
return false;
}
beginRemoveRows({}, row, row+count-1);
auto begin = std::begin(devices) + row;
auto begin = std::begin(registerGroups) + row;
auto end = begin + count;
devices.erase(begin, end);
registerGroups.erase(begin, end);
endRemoveRows();
disconnect(m_controller, &DmxController::registerGroupRemoved,
this, &RegisterGroupsModel::otherRegisterGroupRemoved);
emit m_controller->registerGroupRemoved(row, row+count-1);
connect(m_controller, &DmxController::registerGroupRemoved,
this, &RegisterGroupsModel::otherRegisterGroupRemoved);
return true;
}
void RegisterGroupsModel::otherRegisterGroupInserted(int first, int last)
{
if (!m_controller)
{
qWarning() << "hilfe" << __LINE__;
return;
}
beginInsertRows({}, first, last);
endInsertRows();
}
void RegisterGroupsModel::otherRegisterGroupRemoved(int first, int last)
{
if (!m_controller)
{
qWarning() << "hilfe" << __LINE__;
return;
}
beginRemoveRows({}, first, last);
endRemoveRows();
}
void RegisterGroupsModel::otherRegisterGroupNameChanged(int row, const QString &name)
{
if (!m_controller)
{
qWarning() << "hilfe" << __LINE__;
return;
}
const auto index = this->index(row);
emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole });
}
namespace {
void registrierDenShit()
{

View File

@ -28,6 +28,11 @@ public:
signals:
void controllerChanged(DmxController *controller);
private slots:
void otherRegisterGroupInserted(int first, int last);
void otherRegisterGroupRemoved(int first, int last);
void otherRegisterGroupNameChanged(int row, const QString &name);
private:
DmxController *m_controller{};
};