Implemented setter for register groups model
This commit is contained in:
@ -40,6 +40,14 @@ ColumnLayout {
|
|||||||
SpinBox {
|
SpinBox {
|
||||||
enabled: false
|
enabled: false
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
value: listView.currentData ? listView.currentData.id : -1
|
||||||
|
onValueModified: if (listView.currentData) listView.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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
|
@ -205,9 +205,10 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||||||
device.position = value.value<QVector3D>();
|
device.position = value.value<QVector3D>();
|
||||||
emit dataChanged(index, index, { PositionRole });
|
emit dataChanged(index, index, { PositionRole });
|
||||||
return true;
|
return true;
|
||||||
|
default:
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DevicesModel::insertRows(int row, int count, const QModelIndex &parent)
|
bool DevicesModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||||
|
@ -250,7 +250,6 @@ bool DeviceTypeRegistersModel::setData(const QModelIndex &index, const QVariant
|
|||||||
this, &DeviceTypeRegistersModel::otherDeviceTypeRegisterTypeChanged);
|
this, &DeviceTypeRegistersModel::otherDeviceTypeRegisterTypeChanged);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qWarning() << "hilfe" << __LINE__;
|
qWarning() << "hilfe" << __LINE__;
|
||||||
return false;
|
return false;
|
||||||
|
@ -209,9 +209,10 @@ bool DeviceTypesModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
deviceType.iconName = value.toString();
|
deviceType.iconName = value.toString();
|
||||||
emit dataChanged(index, index, { IconNameRole });
|
emit dataChanged(index, index, { IconNameRole });
|
||||||
return true;
|
return true;
|
||||||
|
default:
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceTypesModel::insertRows(int row, int count, const QModelIndex &parent)
|
bool DeviceTypesModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||||
|
@ -118,6 +118,61 @@ QHash<int, QByteArray> RegisterGroupsModel::roleNames() const
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RegisterGroupsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_controller)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ®isterGroups = m_controller->lightProject().registerGroups;
|
||||||
|
if (index.row() < 0 || index.row() >= registerGroups.size())
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index.column() != 0)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ®isterGroup = registerGroups.at(index.row());
|
||||||
|
switch (role)
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
case Qt::EditRole:
|
||||||
|
if (value.userType() != QMetaType::QString)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
registerGroup.name = value.toString();
|
||||||
|
emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole });
|
||||||
|
return true;
|
||||||
|
case IdRole:
|
||||||
|
if (value.userType() != QMetaType::Int)
|
||||||
|
{
|
||||||
|
qWarning() << "hilfe" << __LINE__ << value.userType();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
registerGroup.id = value.toInt();
|
||||||
|
emit dataChanged(index, index, { IdRole });
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
qWarning() << "hilfe" << __LINE__;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void registrierDenShit()
|
void registrierDenShit()
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,8 @@ public:
|
|||||||
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
|
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void controllerChanged(DmxController *controller);
|
void controllerChanged(DmxController *controller);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user