Commit 24e5a2b2 authored by Leander Schulten's avatar Leander Schulten
Browse files

Fix removal of entries in the ModelView (Overloading in c++ called from qml is no longer supported)

parent 7b7da840
Pipeline #148665 passed with stage
in 2 minutes and 21 seconds
......@@ -69,19 +69,19 @@ public:
programs.push_back(std::make_unique<DMX::Programm>(std::forward<Args>(args)...));
QQmlEngine::setObjectOwnership(programs.back().get(),QQmlEngine::CppOwnership);
}
Q_INVOKABLE void remove(DMX::Device* device){
Q_INVOKABLE void removeDmxDevice(DMX::Device* device){
if(device)
devices.remove_if([=](const auto & p){return p.get() == device;});
}
Q_INVOKABLE void remove(DMX::DevicePrototype* devicePrototype){
Q_INVOKABLE void removeDmxDevicePrototype(DMX::DevicePrototype* devicePrototype){
if(devicePrototype)
devicePrototypes.remove_if([=](const auto & p){return p.get() == devicePrototype;});
}
Q_INVOKABLE void remove(DMX::Programm* program){
Q_INVOKABLE void removeDmxProgram(DMX::Programm* program){
if(program)
programs.remove_if([=](const auto & p){return p.get() == program;});
}
Q_INVOKABLE void remove(DMX::ProgrammPrototype* programPrototype){
Q_INVOKABLE void removeDmxProgramPrototype(DMX::ProgrammPrototype* programPrototype){
if(programPrototype)
programPrototypes.remove_if([=](const auto & p){return p.get() == programPrototype;});
}
......
......@@ -40,6 +40,7 @@ ModelView{
}
onAddClicked: ModelManager.addDevicePrototype("New DevicePrototype");
onRemoveClicked: ModelManager.removeDmxDevicePrototype(remove);
RowLayout{
Layout.row: 3
......
......@@ -10,7 +10,8 @@ ModelView{
model: deviceModel
nameFunction: function(modelData){return modelData.name + ", Channel: " + modelData.startDMXChannel + (modelData.prototype.numberOfChannels > 1 ? " - " + (modelData.startDMXChannel + modelData.prototype.numberOfChannels - 1) : "");}
rows: 7
onAddClicked:dialog.visible = true
onAddClicked: dialog.visible = true
onRemoveClicked: ModelManager.removeDmxDevice(remove);
addButtonEnabled: UserManagment.currentUser.havePermission(Permission.ADD_DEVICE)
removeButtonEnabled: UserManagment.currentUser.havePermission(Permission.REMOVE_DEVICE)
nameInputEnabled: UserManagment.currentUser.havePermission(Permission.CHANGE_NAME)
......
......@@ -10,6 +10,7 @@ GridLayout{
columns: 4
rows: 4
signal addClicked()
signal removeClicked(var remove)
property alias model : listView.model
property alias currentItem : listView.currentItem
property var currentModelData : listView.currentItem ? listView.currentItem.modelItemData : null
......@@ -59,7 +60,7 @@ GridLayout{
id: buttonRemove
text:"Remove"
font.pixelSize: 15
onClicked: ModelManager.remove(currentModelData)
onClicked: removeClicked(currentModelData)
}
......
......@@ -11,6 +11,8 @@ ModelView{
addButton.text: "Add Prototype"
removeButton.text: "Remove Prototype"
onAddClicked: dialog.visible = true
onRemoveClicked: ModelManager.removeDmxProgramPrototype(remove);
ListView{
clip:true
......@@ -98,7 +100,6 @@ ModelView{
}
onAddClicked: dialog.visible = true
Dialog{
modality: Qt.WindowModal
......
......@@ -11,6 +11,8 @@ ModelView{
rowSpacing: 2
addButton.text: "Add Programm"
removeButton.text: "Remove Programm"
onAddClicked: ModelManager.addProgramm("New Programm");
onRemoveClicked: ModelManager.removeDmxProgram(remove);
Label{
text: "Speed : "
......@@ -138,7 +140,6 @@ ModelView{
}
}
onAddClicked: ModelManager.addProgramm("New Programm");
RowLayout{
Layout.row: 8
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment