Add register groups model
This commit is contained in:
@@ -18,6 +18,7 @@ qt_add_executable(applightcontrol
|
|||||||
lightproject.h lightproject.cpp
|
lightproject.h lightproject.cpp
|
||||||
devicesmodel.h devicesmodel.cpp
|
devicesmodel.h devicesmodel.cpp
|
||||||
devicetyperegistersmodel.h devicetyperegistersmodel.cpp
|
devicetyperegistersmodel.h devicetyperegistersmodel.cpp
|
||||||
|
registergroupsmodel.h registergroupsmodel.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_add_qml_module(applightcontrol
|
qt_add_qml_module(applightcontrol
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
import com.büro
|
import lightcontrol
|
||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
ListElement { text: qsTr('Dummy'); value: DeviceTypeRegisterType.Dummy }
|
ListElement { text: qsTr('Dummy'); value: DeviceTypeRegisterType.Dummy }
|
||||||
|
@@ -3,7 +3,7 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Controls.Material
|
import QtQuick.Controls.Material
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
import com.büro 1.0
|
import lightcontrol
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Label {
|
Label {
|
||||||
|
@@ -3,7 +3,7 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Controls.Material
|
import QtQuick.Controls.Material
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
import com.büro
|
import lightcontrol
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Label {
|
Label {
|
||||||
|
@@ -2,8 +2,6 @@ import QtQuick
|
|||||||
import QtQuick.Controls.Material
|
import QtQuick.Controls.Material
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
import com.büro 1.0
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: homePage
|
id: homePage
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ import QtQuick.Layouts
|
|||||||
import QtQuick.Window
|
import QtQuick.Window
|
||||||
import QtQuick.VirtualKeyboard
|
import QtQuick.VirtualKeyboard
|
||||||
|
|
||||||
import com.büro 1.0
|
import lightcontrol
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: window
|
id: window
|
||||||
|
@@ -4,7 +4,7 @@ import QtQuick.Layouts
|
|||||||
import QtQuick.Window
|
import QtQuick.Window
|
||||||
import QtQuick.VirtualKeyboard
|
import QtQuick.VirtualKeyboard
|
||||||
|
|
||||||
import com.büro 1.0
|
import lightcontrol
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
property variant light
|
property variant light
|
||||||
|
@@ -3,7 +3,7 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Controls.Material
|
import QtQuick.Controls.Material
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
import com.büro 1.0
|
import lightcontrol
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
property bool needsRegler: true
|
property bool needsRegler: true
|
||||||
@@ -21,6 +21,10 @@ ColumnLayout {
|
|||||||
Layout.preferredWidth: 300
|
Layout.preferredWidth: 300
|
||||||
Layout.maximumWidth: 300
|
Layout.maximumWidth: 300
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
model: RegisterGroupsModel {
|
||||||
|
controller: __controller
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
@@ -2,7 +2,7 @@ import QtQuick
|
|||||||
import QtQuick.Controls.Material
|
import QtQuick.Controls.Material
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
import com.büro 1.0
|
import lightcontrol
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
property alias deviceTypeId: deviceTypeRegistersModel.deviceTypeId
|
property alias deviceTypeId: deviceTypeRegistersModel.deviceTypeId
|
||||||
|
@@ -6,10 +6,12 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
|
||||||
constexpr auto IdRole = Qt::UserRole;
|
enum {
|
||||||
constexpr auto DeviceTypeIdRole = Qt::UserRole + 1;
|
IdRole = Qt::UserRole,
|
||||||
constexpr auto AddressRole = Qt::UserRole + 2;
|
DeviceTypeIdRole,
|
||||||
constexpr auto PositionRole = Qt::UserRole + 3;
|
AddressRole,
|
||||||
|
PositionRole
|
||||||
|
};
|
||||||
|
|
||||||
void DevicesModel::setController(DmxController *controller)
|
void DevicesModel::setController(DmxController *controller)
|
||||||
{
|
{
|
||||||
@@ -33,7 +35,8 @@ int DevicesModel::rowCount(const QModelIndex &parent) const
|
|||||||
if (!m_controller)
|
if (!m_controller)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return m_controller->lightProject().devices.size();
|
const auto &devices = m_controller->lightProject().devices;
|
||||||
|
return devices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DevicesModel::data(const QModelIndex &index, int role) const
|
QVariant DevicesModel::data(const QModelIndex &index, int role) const
|
||||||
@@ -291,9 +294,9 @@ bool DevicesModel::removeRows(int row, int count, const QModelIndex &parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void registerDenShit()
|
void registrierDenShit()
|
||||||
{
|
{
|
||||||
qmlRegisterType<DevicesModel>("com.büro", 1, 0, "DevicesModel");
|
qmlRegisterType<DevicesModel>("lightcontrol", 1, 0, "DevicesModel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_COREAPP_STARTUP_FUNCTION(registerDenShit)
|
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "dmxcontroller.h"
|
#include "dmxcontroller.h"
|
||||||
|
|
||||||
|
@@ -65,7 +65,8 @@ int DeviceTypeRegistersModel::rowCount(const QModelIndex &parent) const
|
|||||||
if (m_deviceTypeId == -1)
|
if (m_deviceTypeId == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
auto deviceTypePtr = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
const auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||||
|
auto deviceTypePtr = deviceTypes.findById(m_deviceTypeId);
|
||||||
if (!deviceTypePtr)
|
if (!deviceTypePtr)
|
||||||
{
|
{
|
||||||
qWarning() << "hilfe" << __LINE__;
|
qWarning() << "hilfe" << __LINE__;
|
||||||
@@ -97,7 +98,8 @@ QVariant DeviceTypeRegistersModel::data(const QModelIndex &index, int role) cons
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto deviceTypePtr = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
const auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||||
|
auto deviceTypePtr = deviceTypes.findById(m_deviceTypeId);
|
||||||
if (!deviceTypePtr)
|
if (!deviceTypePtr)
|
||||||
{
|
{
|
||||||
qWarning() << "hilfe" << __LINE__;
|
qWarning() << "hilfe" << __LINE__;
|
||||||
@@ -153,7 +155,8 @@ QMap<int, QVariant> DeviceTypeRegistersModel::itemData(const QModelIndex &index)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto deviceTypePtr = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
const auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||||
|
auto deviceTypePtr = deviceTypes.findById(m_deviceTypeId);
|
||||||
if (!deviceTypePtr)
|
if (!deviceTypePtr)
|
||||||
{
|
{
|
||||||
qWarning() << "hilfe" << __LINE__;
|
qWarning() << "hilfe" << __LINE__;
|
||||||
@@ -210,7 +213,8 @@ bool DeviceTypeRegistersModel::setData(const QModelIndex &index, const QVariant
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto deviceTypePtr = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||||
|
auto deviceTypePtr = deviceTypes.findById(m_deviceTypeId);
|
||||||
if (!deviceTypePtr)
|
if (!deviceTypePtr)
|
||||||
{
|
{
|
||||||
qWarning() << "hilfe" << __LINE__;
|
qWarning() << "hilfe" << __LINE__;
|
||||||
@@ -273,7 +277,8 @@ bool DeviceTypeRegistersModel::insertRows(int row, int count, const QModelIndex
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto deviceTypePtr = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||||
|
auto deviceTypePtr = deviceTypes.findById(m_deviceTypeId);
|
||||||
if (!deviceTypePtr)
|
if (!deviceTypePtr)
|
||||||
{
|
{
|
||||||
qWarning() << "hilfe" << __LINE__;
|
qWarning() << "hilfe" << __LINE__;
|
||||||
@@ -325,7 +330,8 @@ bool DeviceTypeRegistersModel::removeRows(int row, int count, const QModelIndex
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto deviceTypePtr = m_controller->lightProject().deviceTypes.findById(m_deviceTypeId);
|
auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||||
|
auto deviceTypePtr = deviceTypes.findById(m_deviceTypeId);
|
||||||
if (!deviceTypePtr)
|
if (!deviceTypePtr)
|
||||||
{
|
{
|
||||||
qWarning() << "hilfe" << __LINE__;
|
qWarning() << "hilfe" << __LINE__;
|
||||||
@@ -433,10 +439,10 @@ void DeviceTypeRegistersModel::otherDeviceTypeRegisterTypeChanged(const DeviceTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void registerDenShit()
|
void registrierDenShit()
|
||||||
{
|
{
|
||||||
qmlRegisterType<DeviceTypeRegistersModel>("com.büro", 1, 0, "DeviceTypeRegistersModel");
|
qmlRegisterType<DeviceTypeRegistersModel>("lightcontrol", 1, 0, "DeviceTypeRegistersModel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_COREAPP_STARTUP_FUNCTION(registerDenShit)
|
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "dmxcontroller.h"
|
#include "dmxcontroller.h"
|
||||||
|
|
||||||
|
@@ -53,7 +53,8 @@ int DeviceTypesModel::rowCount(const QModelIndex &parent) const
|
|||||||
if (!m_controller)
|
if (!m_controller)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return m_controller->lightProject().deviceTypes.size();
|
const auto &deviceTypes = m_controller->lightProject().deviceTypes;
|
||||||
|
return deviceTypes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DeviceTypesModel::data(const QModelIndex &index, int role) const
|
QVariant DeviceTypesModel::data(const QModelIndex &index, int role) const
|
||||||
@@ -345,9 +346,9 @@ void DeviceTypesModel::otherDeviceTypeNameChanged(int row, const QString &name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void registerDenShit()
|
void registrierDenShit()
|
||||||
{
|
{
|
||||||
qmlRegisterType<DeviceTypesModel>("com.büro", 1, 0, "DeviceTypesModel");
|
qmlRegisterType<DeviceTypesModel>("lightcontrol", 1, 0, "DeviceTypesModel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_COREAPP_STARTUP_FUNCTION(registerDenShit)
|
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "dmxcontroller.h"
|
#include "dmxcontroller.h"
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ DmxController::DmxController(QObject *parent) :
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
.devices {
|
.devices {
|
||||||
{ .id=1, .name="Lampe 1", .deviceTypeId=4, .address=1 },
|
{ .id=0, .name="Lampe 1", .deviceTypeId=4, .address=1 },
|
||||||
{ .id=1, .name="Lampe 2", .deviceTypeId=4, .address=8 },
|
{ .id=1, .name="Lampe 2", .deviceTypeId=4, .address=8 },
|
||||||
{ .id=2, .name="Lampe 3", .deviceTypeId=4, .address=15 },
|
{ .id=2, .name="Lampe 3", .deviceTypeId=4, .address=15 },
|
||||||
{ .id=3, .name="Lampe 4", .deviceTypeId=4, .address=22 },
|
{ .id=3, .name="Lampe 4", .deviceTypeId=4, .address=22 },
|
||||||
@@ -75,26 +75,40 @@ DmxController::DmxController(QObject *parent) :
|
|||||||
{ .id=7, .name="Lampe 8", .deviceTypeId=4, .address=50 },
|
{ .id=7, .name="Lampe 8", .deviceTypeId=4, .address=50 },
|
||||||
{ .id=8, .name="Lampe 9", .deviceTypeId=4, .address=57 },
|
{ .id=8, .name="Lampe 9", .deviceTypeId=4, .address=57 },
|
||||||
{ .id=9, .name="Lampe 10", .deviceTypeId=4, .address=64 },
|
{ .id=9, .name="Lampe 10", .deviceTypeId=4, .address=64 },
|
||||||
{ .id=1, .name="Lampe 11", .deviceTypeId=4, .address=71 },
|
{ .id=10, .name="Lampe 11", .deviceTypeId=4, .address=71 },
|
||||||
{ .id=1, .name="Lampe 12", .deviceTypeId=4, .address=78 },
|
{ .id=11, .name="Lampe 12", .deviceTypeId=4, .address=78 },
|
||||||
{ .id=2, .name="Lampe 13", .deviceTypeId=4, .address=85 },
|
{ .id=12, .name="Lampe 13", .deviceTypeId=4, .address=85 },
|
||||||
{ .id=0, .name="Test 1", .deviceTypeId=1, .address=95 },
|
{ .id=13, .name="Test 1", .deviceTypeId=1, .address=95 },
|
||||||
{ .id=15, .name="Test 2", .deviceTypeId=2, .address=120 },
|
{ .id=14, .name="Test 2", .deviceTypeId=2, .address=120 },
|
||||||
{ .id=11, .name="Moving Head 1", .deviceTypeId=0, .address=150 },
|
{ .id=15, .name="Moving Head 1", .deviceTypeId=0, .address=150 },
|
||||||
{ .id=12, .name="Moving Head 2", .deviceTypeId=0, .address=160 },
|
{ .id=16, .name="Moving Head 2", .deviceTypeId=0, .address=160 },
|
||||||
{ .id=13, .name="Moving Head 3", .deviceTypeId=0, .address=170 },
|
{ .id=17, .name="Moving Head 3", .deviceTypeId=0, .address=170 },
|
||||||
{ .id=14, .name="Moving Head 4", .deviceTypeId=0, .address=180 },
|
{ .id=18, .name="Moving Head 4", .deviceTypeId=0, .address=180 },
|
||||||
{ .id=0, .name="Nebelmaschine", .deviceTypeId=3, .address=200 }
|
{ .id=19, .name="Nebelmaschine", .deviceTypeId=3, .address=200 }
|
||||||
|
},
|
||||||
|
.registerGroups {
|
||||||
|
{ .id=0, .name="Alle Dimmmer" },
|
||||||
|
{ .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 Strobo" },
|
||||||
|
{ .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=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" },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::fill(std::begin(buf), std::end(buf), 0);
|
std::fill(std::begin(buf), std::end(buf), 0);
|
||||||
|
|
||||||
buf[32] = 255;
|
|
||||||
buf[33] = 255;
|
|
||||||
buf[34] = 0;
|
|
||||||
buf[35] = 0;
|
|
||||||
// buf[36] = 255;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DmxController::start()
|
bool DmxController::start()
|
||||||
|
@@ -4,9 +4,9 @@
|
|||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void registerDenShit()
|
void registrierDenShit()
|
||||||
{
|
{
|
||||||
qmlRegisterUncreatableMetaObject(hilfe::staticMetaObject, "com.büro", 1, 0, "DeviceTypeRegisterType", "lass es du depp");
|
qmlRegisterUncreatableMetaObject(hilfe::staticMetaObject, "lightcontrol", 1, 0, "DeviceTypeRegisterType", "lass es du depp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_COREAPP_STARTUP_FUNCTION(registerDenShit)
|
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
||||||
|
@@ -72,8 +72,15 @@ struct LightConfig
|
|||||||
QVector3D position;
|
QVector3D position;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RegisterGroupConfig
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
QString name;
|
||||||
|
};
|
||||||
|
|
||||||
struct LightProject
|
struct LightProject
|
||||||
{
|
{
|
||||||
DeviceTypesContainer deviceTypes;
|
DeviceTypesContainer deviceTypes;
|
||||||
std::vector<LightConfig> devices;
|
std::vector<LightConfig> devices;
|
||||||
|
std::vector<RegisterGroupConfig> registerGroups;
|
||||||
};
|
};
|
||||||
|
127
registergroupsmodel.cpp
Normal file
127
registergroupsmodel.cpp
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
#include "registergroupsmodel.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QQmlEngine>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
IdRole = Qt::UserRole,
|
||||||
|
};
|
||||||
|
|
||||||
|
void RegisterGroupsModel::setController(DmxController *controller)
|
||||||
|
{
|
||||||
|
if (m_controller == controller)
|
||||||
|
return;
|
||||||
|
|
||||||
|
beginResetModel();
|
||||||
|
m_controller = controller;
|
||||||
|
endResetModel();
|
||||||
|
emit controllerChanged(m_controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
int RegisterGroupsModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if (parent.isValid())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_controller)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
const auto ®isterGroups = m_controller->lightProject().registerGroups;
|
||||||
|
return registerGroups.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant RegisterGroupsModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_controller)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ®isterGroups = m_controller->lightProject().registerGroups;
|
||||||
|
|
||||||
|
if (index.row() < 0 || index.row() >= registerGroups.size())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index.column() != 0)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ®isterGroup = registerGroups.at(index.row());
|
||||||
|
|
||||||
|
switch (role)
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
case Qt::EditRole: return registerGroup.name;
|
||||||
|
case IdRole: return registerGroup.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<int, QVariant> RegisterGroupsModel::itemData(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_controller)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ®isterGroups = m_controller->lightProject().registerGroups;
|
||||||
|
|
||||||
|
if (index.row() < 0 || index.row() >= registerGroups.size())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index.column() != 0)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ®isterGroup = registerGroups.at(index.row());
|
||||||
|
|
||||||
|
return {
|
||||||
|
{ Qt::DisplayRole, registerGroup.name },
|
||||||
|
{ IdRole, registerGroup.id }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<int, QByteArray> RegisterGroupsModel::roleNames() const
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
{ Qt::DisplayRole, "name" },
|
||||||
|
{ IdRole, "id" }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void registrierDenShit()
|
||||||
|
{
|
||||||
|
qmlRegisterType<RegisterGroupsModel>("lightcontrol", 1, 0, "RegisterGroupsModel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Q_COREAPP_STARTUP_FUNCTION(registrierDenShit)
|
29
registergroupsmodel.h
Normal file
29
registergroupsmodel.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
|
#include "dmxcontroller.h"
|
||||||
|
|
||||||
|
class RegisterGroupsModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(DmxController* controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
using QAbstractListModel::QAbstractListModel;
|
||||||
|
|
||||||
|
DmxController *controller() { return m_controller; }
|
||||||
|
const DmxController *controller() const { return m_controller; }
|
||||||
|
void setController(DmxController *controller);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DmxController *m_controller{};
|
||||||
|
};
|
Reference in New Issue
Block a user