Fixed QML_ELEMENT macro, preset steps model preperations
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(scheincommander VERSION 0.9 LANGUAGES CXX)
|
||||
project(scheincommander VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
#set(CMAKE_CXX_STANDARD 23)
|
||||
@ -14,7 +14,9 @@ if(CCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif(CCACHE_FOUND)
|
||||
|
||||
find_package(Qt6 6.2 REQUIRED COMPONENTS SerialPort Quick)
|
||||
find_package(Qt6 6.4 REQUIRED COMPONENTS Quick SerialPort)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(appscheincommander
|
||||
main.cpp
|
||||
@ -30,6 +32,7 @@ qt_add_executable(appscheincommander
|
||||
projectloader.h projectloader.cpp
|
||||
scheincommandersettings.h scheincommandersettings.cpp
|
||||
iconutils.h iconutils.cpp
|
||||
presetstepsmodel.h presetstepsmodel.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(appscheincommander
|
||||
@ -56,7 +59,6 @@ qt_add_qml_module(appscheincommander
|
||||
DmxSlider.qml
|
||||
StatusBar.qml
|
||||
PresetsSettingsPage.qml
|
||||
RegistersSettingsItem.qml
|
||||
IconComboBox.qml
|
||||
IconsModel.qml
|
||||
DeviceTypeRegisterTypesModel.qml
|
||||
@ -79,8 +81,8 @@ set_target_properties(appscheincommander PROPERTIES
|
||||
|
||||
target_link_libraries(appscheincommander
|
||||
PRIVATE
|
||||
Qt6::SerialPort
|
||||
Qt6::Quick
|
||||
Qt6::SerialPort
|
||||
)
|
||||
|
||||
install(TARGETS appscheincommander
|
||||
|
@ -14,7 +14,7 @@ ColumnLayout {
|
||||
Layout.fillHeight: true
|
||||
|
||||
EditableListView {
|
||||
id: listView
|
||||
id: deviceTypesListView
|
||||
|
||||
iconSourceRole: "iconUrl"
|
||||
|
||||
@ -62,32 +62,28 @@ ColumnLayout {
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
enabled: listView.currentIndex !== -1
|
||||
Layout.fillHeight: true
|
||||
|
||||
enabled: deviceTypesListView.currentIndex !== -1
|
||||
|
||||
GridLayout {
|
||||
Layout.preferredWidth: 600
|
||||
Layout.maximumWidth: 600
|
||||
|
||||
columns: 2
|
||||
|
||||
Label { text: qsTr("Id:") }
|
||||
SpinBox {
|
||||
enabled: false
|
||||
Layout.fillWidth: true
|
||||
value: listView.currentData ? listView.currentData.id : -1
|
||||
onValueModified: if (listView.currentData) listView.currentData.id = value; else console.warn('discarded');
|
||||
value: deviceTypesListView.currentData ? deviceTypesListView.currentData.id : -1
|
||||
onValueModified: if (deviceTypesListView.currentData) deviceTypesListView.currentData.id = value; else console.warn('discarded');
|
||||
}
|
||||
Label { text: qsTr("Name:") }
|
||||
TextField {
|
||||
Layout.fillWidth: true
|
||||
text: listView.currentData ? listView.currentData.name : ''
|
||||
onTextEdited: if (listView.currentData) listView.currentData.name = text; else console.warn('discarded');
|
||||
text: deviceTypesListView.currentData ? deviceTypesListView.currentData.name : ''
|
||||
onTextEdited: if (deviceTypesListView.currentData) deviceTypesListView.currentData.name = text; else console.warn('discarded');
|
||||
}
|
||||
Label { text: qsTr("Icon:") }
|
||||
IconComboBox {
|
||||
id: iconComboBox
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 64
|
||||
|
||||
textRole: "fileBaseName"
|
||||
@ -98,26 +94,74 @@ ColumnLayout {
|
||||
id: iconsModel
|
||||
}
|
||||
|
||||
currentIndex: listView.currentData ? iconComboBox.indexOfValue(listView.currentData.iconName) : -1
|
||||
currentIndex: deviceTypesListView.currentData ? iconComboBox.indexOfValue(deviceTypesListView.currentData.iconName) : -1
|
||||
Component.onCompleted: {
|
||||
iconsModel.onRowCountChanged.connect(function(){
|
||||
currentIndex = Qt.binding(function() { return listView.currentData ? iconComboBox.indexOfValue(listView.currentData.iconName) : -1});
|
||||
currentIndex = Qt.binding(function() { return deviceTypesListView.currentData ? iconComboBox.indexOfValue(deviceTypesListView.currentData.iconName) : -1});
|
||||
});
|
||||
}
|
||||
|
||||
onActivated: if (listView.currentData) listView.currentData.iconName = currentValue; else console.warn('discarded');
|
||||
}
|
||||
Label { text: qsTr("Registers:") }
|
||||
RegistersSettingsItem {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
deviceTypeId: listView.currentData ? listView.currentData.id : -1
|
||||
onActivated: if (deviceTypesListView.currentData) deviceTypesListView.currentData.iconName = currentValue; else console.warn('discarded');
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
|
||||
Pane {
|
||||
Layout.preferredWidth: 300
|
||||
Layout.fillHeight: true
|
||||
|
||||
enabled: deviceTypesListView.currentIndex !== -1
|
||||
|
||||
Material.elevation: 6
|
||||
|
||||
EditableListView {
|
||||
id: registersListView
|
||||
anchors.fill: parent
|
||||
|
||||
textRole: 'registerTypeName'
|
||||
|
||||
model: DeviceTypeRegistersModel {
|
||||
id: registersModel
|
||||
controller: __controller
|
||||
|
||||
deviceTypeId: deviceTypesListView.currentData ? deviceTypesListView.currentData.id : -1
|
||||
}
|
||||
|
||||
onAddClicked: (index) => { const newIndex = index < 0 ? 0 : index + 1; if (registersModel.insertRow(newIndex)) currentIndex = newIndex; else console.warn('failed'); }
|
||||
onRemoveClicked: (index) => registersModel.removeRow(index)
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
//Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
enabled: registersListView.currentIndex >= 0
|
||||
|
||||
GridLayout {
|
||||
columns: 2
|
||||
|
||||
Label {
|
||||
text: qsTr('Type:')
|
||||
}
|
||||
ComboBox {
|
||||
id: comboBox
|
||||
model: DeviceTypeRegisterTypesModel {
|
||||
}
|
||||
textRole: "text"
|
||||
valueRole: "value"
|
||||
|
||||
currentIndex: registersListView.currentData ? comboBox.indexOfValue(registersListView.currentData.registerType) : -1
|
||||
onActivated: if (registersListView.currentData) registersListView.currentData.registerType = currentValue; else console.warn('discarded');
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,10 @@ ColumnLayout {
|
||||
value: listView.currentData ? listView.currentData.address : -1
|
||||
onValueModified: listView.currentData.address = value
|
||||
}
|
||||
Label { text: qsTr("Position:") }
|
||||
Label {
|
||||
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
||||
text: qsTr("Position:")
|
||||
}
|
||||
Vector3DField {
|
||||
id: positionField
|
||||
Layout.fillWidth: true
|
||||
|
@ -22,24 +22,20 @@ Flickable {
|
||||
from: "invisible"
|
||||
to: ""
|
||||
reversible: false
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
properties: "y"
|
||||
duration: 1000
|
||||
easing.type: Easing.OutBounce
|
||||
}
|
||||
NumberAnimation {
|
||||
properties: "y"
|
||||
duration: 1000
|
||||
easing.type: Easing.OutBounce
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
from: ""
|
||||
to: "invisible"
|
||||
reversible: false
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
properties: "y"
|
||||
duration: 1000
|
||||
easing.type: Easing.OutBounce
|
||||
}
|
||||
NumberAnimation {
|
||||
properties: "y"
|
||||
duration: 1000
|
||||
easing.type: Easing.OutBounce
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -12,22 +12,21 @@ ColumnLayout {
|
||||
text: qsTr("Presets Settings")
|
||||
}
|
||||
RowLayout {
|
||||
//Layout.fillWidth: true
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
EditableListView {
|
||||
id: listView
|
||||
id: presetsListView
|
||||
|
||||
Layout.preferredWidth: 300
|
||||
Layout.maximumWidth: 300
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
model: PresetsModel {
|
||||
id: model
|
||||
id: presetsModel
|
||||
controller: __controller
|
||||
}
|
||||
|
||||
onAddClicked: (index) => { const newIndex = index < 0 ? 0 : index + 1; if (model.insertRow(newIndex)) currentIndex = newIndex; else console.warn('failed'); }
|
||||
onAddClicked: (index) => { const newIndex = index < 0 ? 0 : index + 1; if (presetsModel.insertRow(newIndex)) currentIndex = newIndex; else console.warn('failed'); }
|
||||
onRemoveClicked: (index) => {
|
||||
const dialog = dialogComponent.createObject(Overlay.overlay);
|
||||
dialog.index = index;
|
||||
@ -45,7 +44,7 @@ ColumnLayout {
|
||||
modal: true
|
||||
title: qsTr('Confirmation')
|
||||
|
||||
onAccepted: model.removeRow(index)
|
||||
onAccepted: presetsModel.removeRow(index)
|
||||
|
||||
Label {
|
||||
id: textContainer
|
||||
@ -62,51 +61,23 @@ ColumnLayout {
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
enabled: listView.currentIndex !== -1
|
||||
Layout.fillHeight: true
|
||||
|
||||
enabled: presetsListView.currentIndex !== -1
|
||||
|
||||
GridLayout {
|
||||
Layout.preferredWidth: 300
|
||||
Layout.maximumWidth: 300
|
||||
|
||||
columns: 2
|
||||
|
||||
Label { text: qsTr("Id:") }
|
||||
SpinBox {
|
||||
enabled: false
|
||||
Layout.fillWidth: true
|
||||
value: listView.currentData ? listView.currentData.id : -1
|
||||
onValueModified: if (listView.currentData) listView.currentData.id = value; else console.warn('discarded');
|
||||
value: presetsListView.currentData ? presetsListView.currentData.id : -1
|
||||
onValueModified: if (presetsListView.currentData) presetsListView.currentData.id = value; else console.warn('discarded');
|
||||
}
|
||||
Label { text: qsTr("Name:") }
|
||||
TextField {
|
||||
Layout.fillWidth: true
|
||||
text: listView.currentData ? listView.currentData.name : ''
|
||||
onTextEdited: if (listView.currentData) listView.currentData.name = text; else console.warn('discarded');
|
||||
}
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
columns: 3
|
||||
|
||||
PresetModel {
|
||||
id: presetModel
|
||||
controller: __controller
|
||||
presetId: listView.currentData ? listView.currentData.id : -1
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr('Auf Schieberegler\nunten kopieren');
|
||||
onPressed: presetModel.copyToFaders()
|
||||
}
|
||||
Button {
|
||||
text: qsTr('Von Schieberegler\nunten kopieren');
|
||||
onPressed: presetModel.copyFromFaders()
|
||||
}
|
||||
Item {
|
||||
Layout.rowSpan: 2
|
||||
Layout.fillWidth: true
|
||||
text: presetsListView.currentData ? presetsListView.currentData.name : ''
|
||||
onTextEdited: if (presetsListView.currentData) presetsListView.currentData.name = text; else console.warn('discarded');
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,9 +86,35 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
PresetModel {
|
||||
id: presetModel
|
||||
controller: __controller
|
||||
presetId: presetsListView.currentData ? presetsListView.currentData.id : -1
|
||||
}
|
||||
|
||||
EditableListView {
|
||||
enabled: presetsListView.currentIndex !== -1
|
||||
|
||||
model: PresetStepsModel {
|
||||
controller: __controller
|
||||
presetId: presetsListView.currentData ? presetsListView.currentData.id : -1
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
RowLayout {
|
||||
Button {
|
||||
text: qsTr('Auf Schieberegler\nunten kopieren');
|
||||
onPressed: presetModel.copyToFaders()
|
||||
}
|
||||
Button {
|
||||
text: qsTr('Von Schieberegler\nunten kopieren');
|
||||
onPressed: presetModel.copyFromFaders()
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Button {
|
||||
text: qsTr('Alle auf\n0 setzen');
|
||||
@ -128,6 +125,7 @@ ColumnLayout {
|
||||
onPressed: presetModel.setAllFadersMax()
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
SpinBox {
|
||||
id: nSpinBox
|
||||
@ -160,6 +158,10 @@ ColumnLayout {
|
||||
onPressed: presetModel.setPattern(nSpinBox.value, kSpinBox.value, registerTypeComboBox.currentValue, valueSlider.value)
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Layouts
|
||||
|
||||
import scheincommander 1.0
|
||||
|
||||
Pane {
|
||||
property alias deviceTypeId: model.deviceTypeId
|
||||
|
||||
Material.elevation: 6
|
||||
|
||||
DeviceTypeRegistersModel {
|
||||
id: model
|
||||
controller: __controller
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
Pane {
|
||||
Layout.preferredWidth: 300
|
||||
Layout.fillHeight: true
|
||||
|
||||
Material.elevation: 6
|
||||
|
||||
EditableListView {
|
||||
id: listView
|
||||
anchors.fill: parent
|
||||
|
||||
textRole: 'registerTypeName'
|
||||
|
||||
model: model
|
||||
|
||||
onAddClicked: (index) => { const newIndex = index < 0 ? 0 : index + 1; if (model.insertRow(newIndex)) currentIndex = newIndex; else console.warn('failed'); }
|
||||
onRemoveClicked: (index) => model.removeRow(index)
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
enabled: listView.currentIndex >= 0
|
||||
|
||||
GridLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
columns: 2
|
||||
|
||||
Label {
|
||||
text: qsTr('Type:')
|
||||
}
|
||||
ComboBox {
|
||||
id: comboBox
|
||||
model: DeviceTypeRegisterTypesModel {
|
||||
}
|
||||
textRole: "text"
|
||||
valueRole: "value"
|
||||
|
||||
currentIndex: listView.currentData ? comboBox.indexOfValue(listView.currentData.registerType) : -1
|
||||
onActivated: if (listView.currentData) listView.currentData.registerType = currentValue; else console.warn('discarded');
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
#include "deviceregistervaluehelper.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QQmlEngine>
|
||||
#include <QMutexLocker>
|
||||
|
||||
void DeviceRegisterValueHelper::setController(DmxController *controller)
|
||||
@ -138,12 +136,3 @@ void DeviceRegisterValueHelper::sliderStatesChanged()
|
||||
{
|
||||
emit valueChanged(value());
|
||||
}
|
||||
|
||||
namespace {
|
||||
void registrierDenShit()
|
||||
{
|
||||
qmlRegisterType<DeviceRegisterValueHelper>("scheincommander", 1, 0, "DeviceRegisterValueHelper");
|
||||
}
|
||||
}
|
||||
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <qqml.h>
|
||||
|
||||
#include "dmxcontroller.h"
|
||||
|
||||
class DeviceRegisterValueHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(DmxController* controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
Q_PROPERTY(int deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged)
|
||||
Q_PROPERTY(int registerIndex READ registerIndex WRITE setRegisterIndex NOTIFY registerIndexChanged)
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QQmlEngine>
|
||||
#include <QMutexLocker>
|
||||
|
||||
#include "iconutils.h"
|
||||
@ -543,11 +541,3 @@ void DevicesModel::otherDevicePositionChanged(int row, const QVector3D &position
|
||||
const auto index = this->index(row);
|
||||
emit dataChanged(index, index, { PositionRole, PositionXRole, PositionYRole, PositionZRole });
|
||||
}
|
||||
|
||||
namespace {
|
||||
void registrierDenShit()
|
||||
{
|
||||
qmlRegisterType<DevicesModel>("scheincommander", 1, 0, "DevicesModel");
|
||||
}
|
||||
}
|
||||
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||
|
@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <qqml.h>
|
||||
|
||||
#include "dmxcontroller.h"
|
||||
|
||||
class DevicesModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(DmxController* controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
|
||||
public:
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QQmlEngine>
|
||||
#include <QMutexLocker>
|
||||
|
||||
void DeviceTypeRegistersModel::setController(DmxController *controller)
|
||||
@ -109,7 +107,8 @@ QVariant DeviceTypeRegistersModel::data(const QModelIndex &index, int role) cons
|
||||
|
||||
const auto &deviceType = *deviceTypePtr;
|
||||
|
||||
if (index.row() < 0 || index.row() >= deviceType.registers.size())
|
||||
const auto ®isters = deviceType.registers;
|
||||
if (index.row() < 0 || index.row() >= registers.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
@ -121,14 +120,12 @@ QVariant DeviceTypeRegistersModel::data(const QModelIndex &index, int role) cons
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &deviceTypeRegister = deviceType.registers.at(index.row());
|
||||
const auto &deviceTypeRegister = registers.at(index.row());
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
return QMetaEnum::fromType<DeviceTypeRegisterType>().valueToKey(std::to_underlying(deviceTypeRegister.type));
|
||||
}
|
||||
case Qt::EditRole:
|
||||
return QVariant::fromValue(deviceTypeRegister.type);
|
||||
}
|
||||
@ -446,11 +443,3 @@ void DeviceTypeRegistersModel::otherDeviceTypeRegisterTypeChanged(const DeviceTy
|
||||
const auto index = this->index(row);
|
||||
emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole });
|
||||
}
|
||||
|
||||
namespace {
|
||||
void registrierDenShit()
|
||||
{
|
||||
qmlRegisterType<DeviceTypeRegistersModel>("scheincommander", 1, 0, "DeviceTypeRegistersModel");
|
||||
}
|
||||
}
|
||||
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||
|
@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <qqml.h>
|
||||
|
||||
#include "dmxcontroller.h"
|
||||
|
||||
class DeviceTypeRegistersModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(DmxController* controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
Q_PROPERTY(int deviceTypeId READ deviceTypeId WRITE setDeviceTypeId NOTIFY deviceTypeIdChanged)
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QQmlEngine>
|
||||
#include <QMutexLocker>
|
||||
|
||||
#include "iconutils.h"
|
||||
@ -379,11 +377,3 @@ void DeviceTypesModel::otherDeviceTypeIconNameChanged(int row, const QString &na
|
||||
const auto index = this->index(row);
|
||||
emit dataChanged(index, index, { IconNameRole, IconUrlRole });
|
||||
}
|
||||
|
||||
namespace {
|
||||
void registrierDenShit()
|
||||
{
|
||||
qmlRegisterType<DeviceTypesModel>("scheincommander", 1, 0, "DeviceTypesModel");
|
||||
}
|
||||
}
|
||||
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||
|
@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <qqml.h>
|
||||
|
||||
#include "dmxcontroller.h"
|
||||
|
||||
class DeviceTypesModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(DmxController* controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
|
||||
public:
|
||||
|
@ -14,160 +14,7 @@ DmxController::DmxController(ScheinCommanderSettings &settings, QObject *parent)
|
||||
QObject{parent},
|
||||
m_settings{settings},
|
||||
m_thread{*this},
|
||||
m_lastInfo{QDateTime::currentDateTime()},
|
||||
m_counter{},
|
||||
m_lightProject {
|
||||
.deviceTypes {
|
||||
{
|
||||
.id=0,
|
||||
.name="Stairville MH-X50+",
|
||||
.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,
|
||||
.name="RGBW Strahler Klein",
|
||||
.iconName="rgbstrahler",
|
||||
.registers {
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Dimmer },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Red },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Green },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Blue },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::White },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Shutter },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Extra1 }
|
||||
}
|
||||
},
|
||||
{
|
||||
.id=2,
|
||||
.name="RGB Strahler",
|
||||
.iconName="rgbstrahler",
|
||||
.registers {
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Red },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Green },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Blue }
|
||||
}
|
||||
},
|
||||
{
|
||||
.id=3,
|
||||
.name="Nebelmaschine",
|
||||
.iconName="nebelmaschine",
|
||||
.registers {
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Dimmer }
|
||||
}
|
||||
},
|
||||
{
|
||||
.id=4,
|
||||
.name="RGBW Strahler Groß",
|
||||
.iconName="rgbstrahler",
|
||||
.registers {
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Dimmer },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Red },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Green },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Blue },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::White },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Extra1 },
|
||||
DeviceTypeRegisterConfig { .type = DeviceTypeRegisterType::Shutter }
|
||||
}
|
||||
}
|
||||
},
|
||||
.devices {
|
||||
{ .id=0, .name="Lampe 1", .deviceTypeId=4, .address=1 },
|
||||
{ .id=1, .name="Lampe 2", .deviceTypeId=4, .address=8 },
|
||||
{ .id=2, .name="Lampe 3", .deviceTypeId=4, .address=15 },
|
||||
{ .id=3, .name="Lampe 4", .deviceTypeId=4, .address=22 },
|
||||
{ .id=4, .name="Lampe 5", .deviceTypeId=4, .address=29 },
|
||||
{ .id=5, .name="Lampe 6", .deviceTypeId=4, .address=36 },
|
||||
{ .id=6, .name="Lampe 7", .deviceTypeId=4, .address=43 },
|
||||
{ .id=7, .name="Lampe 8", .deviceTypeId=4, .address=50 },
|
||||
{ .id=8, .name="Lampe 9", .deviceTypeId=4, .address=57 },
|
||||
{ .id=9, .name="Lampe 10", .deviceTypeId=4, .address=64 },
|
||||
{ .id=10, .name="Lampe 11", .deviceTypeId=4, .address=71 },
|
||||
{ .id=11, .name="Lampe 12", .deviceTypeId=4, .address=78 },
|
||||
{ .id=12, .name="Lampe 13", .deviceTypeId=4, .address=85 },
|
||||
{ .id=13, .name="Lampe 14", .deviceTypeId=4, .address=92 },
|
||||
{ .id=14, .name="Lampe 15", .deviceTypeId=4, .address=99 },
|
||||
{ .id=15, .name="Lampe 16", .deviceTypeId=4, .address=106 },
|
||||
{ .id=16, .name="Lampe 17", .deviceTypeId=4, .address=113 },
|
||||
{ .id=17, .name="Lampe 18", .deviceTypeId=4, .address=120 },
|
||||
{ .id=18, .name="Lampe 19", .deviceTypeId=4, .address=127 },
|
||||
{ .id=19, .name="Lampe 20", .deviceTypeId=4, .address=134 },
|
||||
{ .id=20, .name="Lampe 21", .deviceTypeId=4, .address=141 },
|
||||
{ .id=21, .name="Lampe 22", .deviceTypeId=4, .address=148 },
|
||||
{ .id=22, .name="Lampe 23", .deviceTypeId=4, .address=155 },
|
||||
{ .id=23, .name="Lampe 24", .deviceTypeId=4, .address=162 },
|
||||
{ .id=24, .name="Lampe 25", .deviceTypeId=4, .address=169 },
|
||||
{ .id=25, .name="Lampe 26", .deviceTypeId=4, .address=176 },
|
||||
{ .id=26, .name="Lampe 27", .deviceTypeId=4, .address=183 },
|
||||
{ .id=27, .name="Lampe 28", .deviceTypeId=4, .address=190 },
|
||||
{ .id=28, .name="Lampe 29", .deviceTypeId=4, .address=197 },
|
||||
{ .id=29, .name="Lampe 30", .deviceTypeId=4, .address=204 },
|
||||
{ .id=30, .name="Lampe 31", .deviceTypeId=4, .address=211 },
|
||||
{ .id=31, .name="Lampe 32", .deviceTypeId=4, .address=218 },
|
||||
{ .id=32, .name="Lampe 33", .deviceTypeId=4, .address=225 },
|
||||
{ .id=33, .name="Lampe 34", .deviceTypeId=4, .address=232 },
|
||||
{ .id=34, .name="Lampe 35", .deviceTypeId=4, .address=239 },
|
||||
{ .id=35, .name="Lampe 36", .deviceTypeId=4, .address=246 },
|
||||
{ .id=36, .name="Lampe 37", .deviceTypeId=4, .address=253 },
|
||||
{ .id=37, .name="Lampe 38", .deviceTypeId=4, .address=260 },
|
||||
{ .id=38, .name="Lampe 39", .deviceTypeId=4, .address=267 },
|
||||
{ .id=39, .name="Lampe 40", .deviceTypeId=4, .address=274 },
|
||||
{ .id=40, .name="Lampe 41", .deviceTypeId=4, .address=281 },
|
||||
{ .id=41, .name="Lampe 42", .deviceTypeId=4, .address=288 },
|
||||
{ .id=42, .name="Lampe 43", .deviceTypeId=4, .address=295 },
|
||||
{ .id=43, .name="Lampe 44", .deviceTypeId=4, .address=302 },
|
||||
{ .id=44, .name="Lampe 45", .deviceTypeId=4, .address=309 },
|
||||
{ .id=45, .name="Lampe 46", .deviceTypeId=4, .address=316 },
|
||||
{ .id=46, .name="Lampe 47", .deviceTypeId=4, .address=323 },
|
||||
{ .id=47, .name="Lampe 48", .deviceTypeId=4, .address=330 },
|
||||
{ .id=48, .name="Lampe 49", .deviceTypeId=4, .address=337 },
|
||||
{ .id=49, .name="Lampe 50", .deviceTypeId=4, .address=344 },
|
||||
{ .id=50, .name="Lampe 51", .deviceTypeId=4, .address=351 },
|
||||
{ .id=51, .name="Lampe 52", .deviceTypeId=4, .address=358 },
|
||||
// { .id=13, .name="Test 1", .deviceTypeId=1, .address=95 },
|
||||
// { .id=14, .name="Test 2", .deviceTypeId=2, .address=105 },
|
||||
// { .id=15, .name="Moving Head 1", .deviceTypeId=0, .address=115 },
|
||||
// { .id=16, .name="Moving Head 2", .deviceTypeId=0, .address=131 },
|
||||
// { .id=17, .name="Moving Head 3", .deviceTypeId=0, .address=147 },
|
||||
// { .id=18, .name="Moving Head 4", .deviceTypeId=0, .address=163 },
|
||||
// { .id=19, .name="Nebelmaschine", .deviceTypeId=3, .address=179 }
|
||||
},
|
||||
.presets {
|
||||
{ .id=0, .name="Alle Dimmer" },
|
||||
{ .id=1, .name="Alle Roten" },
|
||||
{ .id=2, .name="Alle Grünen" },
|
||||
{ .id=3, .name="Alle Blauen" },
|
||||
{ .id=4, .name="Alle Weißen" },
|
||||
{ .id=5, .name="Alle Shutter" },
|
||||
{ .id=6, .name="2n Dimmer" },
|
||||
{ .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 Shutter" },
|
||||
{ .id=12, .name="2n+1 Dimmer" },
|
||||
{ .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 Shutter" },
|
||||
}
|
||||
}
|
||||
m_lastInfo{QDateTime::currentDateTime()}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <qqml.h>
|
||||
#include <QSerialPort>
|
||||
#include <QDateTime>
|
||||
#include <QMutex>
|
||||
@ -12,6 +13,7 @@
|
||||
class DmxController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(ScheinCommanderSettings* settings READ settings CONSTANT)
|
||||
Q_PROPERTY(int dmxFps READ dmxFps NOTIFY dmxFpsChanged)
|
||||
Q_PROPERTY(int dmxMaxElapsed READ dmxMaxElapsed NOTIFY dmxMaxElapsedChanged)
|
||||
@ -92,7 +94,7 @@ private:
|
||||
std::vector<quint8> m_presetStates;
|
||||
|
||||
QDateTime m_lastInfo;
|
||||
int m_counter;
|
||||
int m_counter{};
|
||||
std::atomic<int> m_lastCounter;
|
||||
int m_dmxMaxElapsed{};
|
||||
std::atomic<int> m_lastDmxMaxElapsed;
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace {
|
||||
void registrierDenShit()
|
||||
{
|
||||
qmlRegisterUncreatableMetaObject(hilfe::staticMetaObject, "scheincommander", 1, 0, "DeviceTypeRegisterType", "lass es du depp");
|
||||
qmlRegisterUncreatableMetaObject(scheincommander::staticMetaObject, "scheincommander", 1, 0, "DeviceTypeRegisterType", "lass es du depp");
|
||||
}
|
||||
}
|
||||
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <QMetaEnum>
|
||||
#include <QMetaType>
|
||||
|
||||
namespace hilfe {
|
||||
namespace scheincommander {
|
||||
Q_NAMESPACE
|
||||
enum class DeviceTypeRegisterType
|
||||
{
|
||||
@ -39,11 +39,11 @@ enum class DeviceTypeRegisterType
|
||||
Extra2
|
||||
};
|
||||
Q_ENUM_NS(DeviceTypeRegisterType)
|
||||
} // namespace hilfe
|
||||
} // namespace scheincommander
|
||||
|
||||
Q_DECLARE_METATYPE(hilfe::DeviceTypeRegisterType)
|
||||
Q_DECLARE_METATYPE(scheincommander::DeviceTypeRegisterType)
|
||||
|
||||
using DeviceTypeRegisterType = hilfe::DeviceTypeRegisterType;
|
||||
using DeviceTypeRegisterType = scheincommander::DeviceTypeRegisterType;
|
||||
|
||||
struct DeviceTypeRegisterConfig
|
||||
{
|
||||
|
21
main.cpp
21
main.cpp
@ -10,6 +10,8 @@
|
||||
|
||||
#define STR(x) #x
|
||||
|
||||
void qml_register_types_scheincommander();
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qSetMessagePattern(QStringLiteral("%{time dd.MM.yyyy HH:mm:ss.zzz} "
|
||||
@ -32,9 +34,7 @@ int main(int argc, char *argv[])
|
||||
QCoreApplication::setApplicationVersion(STR(CMAKE_PROJECT_VERSION));
|
||||
|
||||
QGuiApplication app{argc, argv};
|
||||
QIcon icon{":/scheincommander/scheincommander.png"};
|
||||
qDebug() << icon.availableSizes();
|
||||
app.setWindowIcon(icon);
|
||||
app.setWindowIcon(QIcon{":/scheincommander/scheincommander.png"});
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.addHelpOption();
|
||||
@ -67,17 +67,22 @@ int main(int argc, char *argv[])
|
||||
if (!controller.start() && !windowed)
|
||||
return -1;
|
||||
|
||||
qml_register_types_scheincommander();
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
|
||||
engine.rootContext()->setContextProperty("__controller", &controller);
|
||||
engine.rootContext()->setContextProperty("__windowed", windowed);
|
||||
|
||||
const QUrl url{u"qrc:/scheincommander/main.qml"_qs};
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
if (!obj && url == objUrl)
|
||||
QCoreApplication::exit(-1);
|
||||
}, Qt::QueuedConnection);
|
||||
// QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
// &app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
// if (!obj && url == objUrl)
|
||||
// QCoreApplication::exit(-1);
|
||||
// }, Qt::QueuedConnection);
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { qFatal("object creation failed!"); QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.load(url);
|
||||
|
||||
return app.exec();
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "presetmodel.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QQmlEngine>
|
||||
#include <QMutexLocker>
|
||||
|
||||
void PresetModel::setController(DmxController *controller)
|
||||
@ -214,12 +212,3 @@ void PresetModel::setPattern(int n, int k, DeviceTypeRegisterType registerType,
|
||||
|
||||
m_controller->setSliderStates(std::move(sliderStates));
|
||||
}
|
||||
|
||||
namespace {
|
||||
void registrierDenShit()
|
||||
{
|
||||
qmlRegisterType<PresetModel>("scheincommander", 1, 0, "PresetModel");
|
||||
}
|
||||
}
|
||||
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <qqml.h>
|
||||
|
||||
#include "dmxcontroller.h"
|
||||
|
||||
class PresetModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(DmxController* controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
Q_PROPERTY(int presetId READ presetId WRITE setPresetId NOTIFY presetIdChanged)
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QQmlEngine>
|
||||
#include <QMutexLocker>
|
||||
|
||||
enum {
|
||||
@ -363,11 +361,3 @@ void PresetsModel::otherPresetNameChanged(int row, const QString &name)
|
||||
const auto index = this->index(row);
|
||||
emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole });
|
||||
}
|
||||
|
||||
namespace {
|
||||
void registrierDenShit()
|
||||
{
|
||||
qmlRegisterType<PresetsModel>("scheincommander", 1, 0, "PresetsModel");
|
||||
}
|
||||
}
|
||||
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||
|
@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <qqml.h>
|
||||
|
||||
#include "dmxcontroller.h"
|
||||
|
||||
class PresetsModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(DmxController* controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
|
||||
public:
|
||||
|
186
presetstepsmodel.cpp
Normal file
186
presetstepsmodel.cpp
Normal file
@ -0,0 +1,186 @@
|
||||
#include "presetstepsmodel.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
void PresetStepsModel::setController(DmxController *controller)
|
||||
{
|
||||
if (m_controller == controller)
|
||||
return;
|
||||
|
||||
beginResetModel();
|
||||
|
||||
if (m_controller)
|
||||
{
|
||||
// disconnect(m_controller, &DmxController::presetRegisterInserted,
|
||||
// this, &PresetStepsModel::otherPresetRegisterInserted);
|
||||
// disconnect(m_controller, &DmxController::presetRegisterRemoved,
|
||||
// this, &PresetStepsModel::otherPresetRegisterRemoved);
|
||||
// disconnect(m_controller, &DmxController::presetRegisterTypeChanged,
|
||||
// this, &PresetStepsModel::otherPresetRegisterTypeChanged);
|
||||
}
|
||||
|
||||
m_controller = controller;
|
||||
|
||||
if (m_controller)
|
||||
{
|
||||
// connect(m_controller, &DmxController::presetRegisterInserted,
|
||||
// this, &PresetStepsModel::otherPresetRegisterInserted);
|
||||
// connect(m_controller, &DmxController::presetRegisterRemoved,
|
||||
// this, &PresetStepsModel::otherPresetRegisterRemoved);
|
||||
// connect(m_controller, &DmxController::presetRegisterTypeChanged,
|
||||
// this, &PresetStepsModel::otherPresetRegisterTypeChanged);
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
|
||||
emit controllerChanged(m_controller);
|
||||
}
|
||||
|
||||
void PresetStepsModel::setPresetId(int presetId)
|
||||
{
|
||||
if (m_presetId == presetId)
|
||||
return;
|
||||
|
||||
beginResetModel();
|
||||
m_presetId = presetId;
|
||||
endResetModel();
|
||||
emit presetIdChanged(m_presetId);
|
||||
}
|
||||
|
||||
int PresetStepsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!m_controller)
|
||||
return 0;
|
||||
|
||||
if (m_presetId == -1)
|
||||
return 0;
|
||||
|
||||
const auto &presets = m_controller->lightProject().presets;
|
||||
auto presetPtr = presets.findById(m_presetId);
|
||||
if (!presetPtr)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto &preset = *presetPtr;
|
||||
|
||||
return preset.steps.size();
|
||||
}
|
||||
|
||||
QVariant PresetStepsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!m_controller)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (m_presetId == -1)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &presets = m_controller->lightProject().presets;
|
||||
auto presetPtr = presets.findById(m_presetId);
|
||||
if (!presetPtr)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &preset = *presetPtr;
|
||||
|
||||
const auto &steps = preset.steps;
|
||||
if (index.row() < 0 || index.row() >= steps.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (index.column() != 0)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &step = steps.at(index.row());
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return tr("Step %0").arg(index.row() + 1);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QMap<int, QVariant> PresetStepsModel::itemData(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!m_controller)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (m_presetId == -1)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &presets = m_controller->lightProject().presets;
|
||||
auto presetPtr = presets.findById(m_presetId);
|
||||
if (!presetPtr)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &preset = *presetPtr;
|
||||
|
||||
const auto &steps = preset.steps;
|
||||
if (index.row() < 0 || index.row() >= steps.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (index.column() != 0)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &step = steps.at(index.row());
|
||||
|
||||
return {
|
||||
{ Qt::DisplayRole, tr("Step %0").arg(index.row() + 1) }
|
||||
};
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> PresetStepsModel::roleNames() const
|
||||
{
|
||||
return {
|
||||
{ Qt::DisplayRole, "name" },
|
||||
};
|
||||
}
|
37
presetstepsmodel.h
Normal file
37
presetstepsmodel.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <qqml.h>
|
||||
|
||||
#include "dmxcontroller.h"
|
||||
|
||||
class PresetStepsModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(DmxController* controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
Q_PROPERTY(int presetId READ presetId WRITE setPresetId NOTIFY presetIdChanged)
|
||||
|
||||
public:
|
||||
using QAbstractListModel::QAbstractListModel;
|
||||
|
||||
DmxController *controller() { return m_controller; }
|
||||
const DmxController *controller() const { return m_controller; }
|
||||
void setController(DmxController *controller);
|
||||
|
||||
int presetId() const { return m_presetId; }
|
||||
void setPresetId(int presetId);
|
||||
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
signals:
|
||||
void controllerChanged(DmxController *controller);
|
||||
void presetIdChanged(int presetId);
|
||||
|
||||
private:
|
||||
DmxController *m_controller{};
|
||||
int m_presetId{-1};
|
||||
};
|
@ -1,8 +1,5 @@
|
||||
#include "scheincommandersettings.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QQmlEngine>
|
||||
|
||||
namespace {
|
||||
const char KEY_lastProjectFile[] = "lastProjectFile";
|
||||
}
|
||||
@ -17,12 +14,3 @@ void ScheinCommanderSettings::setLastProjectFile(const QString &lastProjectFile)
|
||||
setValue(KEY_lastProjectFile, lastProjectFile);
|
||||
emit lastProjectFileChanged(lastProjectFile);
|
||||
}
|
||||
|
||||
namespace {
|
||||
void registrierDenShit()
|
||||
{
|
||||
qmlRegisterType<ScheinCommanderSettings>("scheincommander", 1, 0, "ScheinCommanderSettings");
|
||||
}
|
||||
}
|
||||
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <QSettings>
|
||||
#include <qqml.h>
|
||||
|
||||
class ScheinCommanderSettings : public QSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(QString lastProjectFile READ lastProjectFile WRITE setLastProjectFile NOTIFY lastProjectFileChanged)
|
||||
|
||||
public:
|
||||
|
Reference in New Issue
Block a user