Implemented creating of new light types or lights

This commit is contained in:
2023-02-15 01:38:00 +01:00
parent 7c580d53b4
commit 9a5e2d3cd7
6 changed files with 90 additions and 2 deletions

View File

@ -234,6 +234,41 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
return false;
}
bool DevicesModel::insertRows(int row, int count, const QModelIndex &parent)
{
if (parent.isValid())
{
qWarning() << "hilfe" << __LINE__;
return false;
}
if (!m_controller)
{
qWarning() << "hilfe" << __LINE__;
return false;
}
auto &lights = m_controller->lightProject().lights;
if (row < 0)
{
qWarning() << "hilfe" << __LINE__;
return false;
}
if (row > lights.size())
{
qWarning() << "hilfe" << __LINE__;
return false;
}
beginInsertRows({}, row, row+count-1);
lights.insert(std::begin(lights) + row, count, LightConfig{ .id=99, .name="<neu>", .lightTypeId=0, .address=0, .position={} });
endInsertRows();
return true;
}
bool DevicesModel::removeRows(int row, int count, const QModelIndex &parent)
{
if (parent.isValid())
@ -250,6 +285,12 @@ bool DevicesModel::removeRows(int row, int count, const QModelIndex &parent)
auto &lights = m_controller->lightProject().lights;
if (row < 0)
{
qWarning() << "hilfe" << __LINE__;
return false;
}
if (row >= lights.size())
{
qWarning() << "hilfe" << __LINE__;