Implemented setter for register groups model
This commit is contained in:
@ -40,6 +40,14 @@ ColumnLayout {
|
||||
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');
|
||||
}
|
||||
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 {
|
||||
|
@ -205,9 +205,10 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
device.position = value.value<QVector3D>();
|
||||
emit dataChanged(index, index, { PositionRole });
|
||||
return true;
|
||||
default:
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
|
@ -209,9 +209,10 @@ bool DeviceTypesModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
deviceType.iconName = value.toString();
|
||||
emit dataChanged(index, index, { IconNameRole });
|
||||
return true;
|
||||
default:
|
||||
qWarning() << "hilfe" << __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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 {
|
||||
void registrierDenShit()
|
||||
{
|
||||
|
@ -21,6 +21,8 @@ public:
|
||||
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
signals:
|
||||
void controllerChanged(DmxController *controller);
|
||||
|
||||
|
Reference in New Issue
Block a user