More preperations for registers in light types
This commit is contained in:
@ -2,6 +2,8 @@ import QtQuick
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Layouts
|
||||
|
||||
import com.büro 1.0
|
||||
|
||||
ColumnLayout {
|
||||
Label {
|
||||
text: qsTr("Device Types Settings")
|
||||
@ -36,20 +38,27 @@ ColumnLayout {
|
||||
Label { text: qsTr("Id:") }
|
||||
SpinBox {
|
||||
Layout.fillWidth: true
|
||||
value: listView.currentItem.myData.id
|
||||
onValueModified: listView.currentItem.myData.id = value
|
||||
value: listView.currentData.id
|
||||
onValueModified: listView.currentData.id = value
|
||||
}
|
||||
Label { text: qsTr("Name:") }
|
||||
TextField {
|
||||
Layout.fillWidth: true
|
||||
text: listView.currentItem.myData.name
|
||||
onTextEdited: listView.currentItem.myData.name = text
|
||||
text: listView.currentData.name
|
||||
onTextEdited: listView.currentData.name = text
|
||||
}
|
||||
Label { text: qsTr("Registers:") }
|
||||
Pane {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
EditableListView {
|
||||
textRole: 'registerTypeName'
|
||||
|
||||
model: DeviceTypeRegistersModel {
|
||||
controller: __controller
|
||||
deviceTypeId: listView.currentData.id
|
||||
}
|
||||
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
|
@ -38,14 +38,14 @@ ColumnLayout {
|
||||
Label { text: qsTr("Id:") }
|
||||
SpinBox {
|
||||
Layout.fillWidth: true
|
||||
value: listView.currentItem.myData.id
|
||||
onValueModified: listView.currentItem.myData.id = value
|
||||
value: listView.currentData.id
|
||||
onValueModified: listView.currentData.id = value
|
||||
}
|
||||
Label { text: qsTr("Name:") }
|
||||
TextField {
|
||||
Layout.fillWidth: true
|
||||
text: listView.currentItem.myData.name
|
||||
onTextEdited: listView.currentItem.myData.name = text
|
||||
text: listView.currentData.name
|
||||
onTextEdited: listView.currentData.name = text
|
||||
}
|
||||
Label { text: qsTr("DeviceType:") }
|
||||
ComboBox {
|
||||
@ -58,14 +58,14 @@ ColumnLayout {
|
||||
Label { text: qsTr("Address:") }
|
||||
SpinBox {
|
||||
Layout.fillWidth: true
|
||||
value: listView.currentItem.myData.address
|
||||
onValueModified: listView.currentItem.myData.address = value
|
||||
value: listView.currentData.address
|
||||
onValueModified: listView.currentData.address = value
|
||||
}
|
||||
Label { text: qsTr("Position:") }
|
||||
Vector3DField {
|
||||
id: test
|
||||
Layout.fillWidth: true
|
||||
onValueModified: listView.currentItem.myData.position = value;
|
||||
onValueModified: listView.currentData.position = value;
|
||||
// TODO solve without onCurrentDataChanged
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ import QtQuick.Controls.Material
|
||||
import QtQuick.Layouts
|
||||
|
||||
ColumnLayout {
|
||||
property string textRole: "name"
|
||||
|
||||
property alias model: listView.model
|
||||
property alias currentIndex: listView.currentIndex
|
||||
property alias currentItem: listView.currentItem
|
||||
@ -59,7 +61,7 @@ ColumnLayout {
|
||||
anchors.fill: parent
|
||||
//anchors.verticalCenter: parent.verticalCenter
|
||||
id: text
|
||||
text: model.name
|
||||
text: model[textRole]
|
||||
padding: 10
|
||||
fontSizeMode: Text.VerticalFit
|
||||
minimumPixelSize: 10;
|
||||
|
@ -108,12 +108,57 @@ QVariant DeviceTypeRegistersModel::data(const QModelIndex &index, int role) cons
|
||||
|
||||
QMap<int, QVariant> DeviceTypeRegistersModel::itemData(const QModelIndex &index) const
|
||||
{
|
||||
// TODO
|
||||
if (!index.isValid())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!m_controller)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (m_deviceTypeId == -1)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
auto lightType = m_controller->lightProject().lightTypes.findById(m_deviceTypeId);
|
||||
if (!lightType)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (index.row() < 0 || index.row() >= lightType->registers.size())
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (index.column() != 0)
|
||||
{
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto &lightTypeRegister = lightType->registers.at(index.row());
|
||||
|
||||
return {
|
||||
{ Qt::DisplayRole, QMetaEnum::fromType<LightTypeRegisterType>().valueToKey(std::to_underlying(lightTypeRegister.type)) },
|
||||
{ Qt::EditRole, QVariant::fromValue(lightTypeRegister.type) }
|
||||
};
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> DeviceTypeRegistersModel::roleNames() const
|
||||
{
|
||||
// TODO
|
||||
return {
|
||||
{ Qt::DisplayRole, "registerTypeName" },
|
||||
{ Qt::EditRole, "registerType" },
|
||||
};
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
Reference in New Issue
Block a user