- fixed a bug that always deleted the first entry instead of the selected oone
This commit is contained in:
parent
19a3601581
commit
f860b3397b
7 changed files with 37 additions and 35 deletions
|
@ -1,4 +1,4 @@
|
||||||
QT += quick bluetooth quickcontrols2
|
QT += gui quick bluetooth quickcontrols2
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
TARGET = ItsblueLedDisplayController
|
TARGET = ItsblueLedDisplayController
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d75f55a3a16a833599cd93e1fb22f2500a94dcf5
|
Subproject commit c72dc564e144315032f1d0d1c132aafdb2392c8c
|
|
@ -20,15 +20,18 @@ QVariant LedDisplayTextModel::data(const QModelIndex &index, int role) const
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant LedDisplayTextModel::data(int row, int role) const {
|
QVariant LedDisplayTextModel::data(int row, int role) const {
|
||||||
if (row < rowCount()) {
|
if (row >= 0 && row < rowCount()) {
|
||||||
if(this->texts[row].contains(role)) {
|
if(this->texts[row].contains(role)) {
|
||||||
if(role == IndexRole)
|
|
||||||
return row;
|
|
||||||
|
|
||||||
QVariant value = this->texts[row][role];
|
QVariant value = this->texts[row][role];
|
||||||
value.convert(this->roleDataTypes[LedDisplayTextModelRole(role)]);
|
value.convert(this->roleDataTypes[LedDisplayTextModelRole(role)]);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
else if(role == IndexRole) {
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "[WARING] Row " << row << "is larger than row count " << rowCount();
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -115,6 +118,7 @@ void LedDisplayTextModel::remove(int row)
|
||||||
if (row < 0 || row >= this->rowCount())
|
if (row < 0 || row >= this->rowCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
qDebug() << "Removing row: " << row;
|
||||||
beginRemoveRows(QModelIndex(), row, row);
|
beginRemoveRows(QModelIndex(), row, row);
|
||||||
this->texts.removeAt(row);
|
this->texts.removeAt(row);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
|
|
@ -69,11 +69,8 @@ Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit() {
|
function edit() {
|
||||||
|
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
nameTextField.value = backend.bleClient.currentDevice.name
|
nameTextField.value = backend.bleClient.currentDevice.name
|
||||||
|
|
||||||
open()
|
open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ ListView {
|
||||||
width: control.width
|
width: control.width
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
popup.edit(model)
|
popup.edit(control.model, model)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,10 +71,5 @@ ListView {
|
||||||
|
|
||||||
Material.theme: control.Material.theme
|
Material.theme: control.Material.theme
|
||||||
Material.accent: control.Material.accent
|
Material.accent: control.Material.accent
|
||||||
|
|
||||||
onDiscarded: {
|
|
||||||
control.model.remove(editingModel.index)
|
|
||||||
popup.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ Dialog {
|
||||||
|
|
||||||
property bool editing
|
property bool editing
|
||||||
property var editingModel
|
property var editingModel
|
||||||
|
property var editingModelData
|
||||||
|
|
||||||
parent: Overlay.overlay
|
parent: Overlay.overlay
|
||||||
|
|
||||||
|
@ -25,15 +26,15 @@ Dialog {
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if(editing) {
|
if(editing) {
|
||||||
editingModel.active = activeSwitch.checked
|
editingModelData.active = activeSwitch.checked
|
||||||
editingModel.text = textTextField.value
|
editingModelData.text = textTextField.value
|
||||||
editingModel.runtime = runtimeSpinBox.value
|
editingModelData.runtime = runtimeSpinBox.value
|
||||||
editingModel.color = colorColorPicker.value
|
editingModelData.color = colorColorPicker.value
|
||||||
editingModel.alignment = alignmentComboBox.currentIndex
|
editingModelData.alignment = alignmentComboBox.currentIndex
|
||||||
editingModel.scroll = scrollSwitch.checked
|
editingModelData.scroll = scrollSwitch.checked
|
||||||
editingModel.scrollDirection = scrollDirectionComboBox.currentIndex
|
editingModelData.scrollDirection = scrollDirectionComboBox.currentIndex
|
||||||
editingModel.scrollSpeed = scrollSpeedSpinBox.value
|
editingModelData.scrollSpeed = scrollSpeedSpinBox.value
|
||||||
editingModel.scrollCount = scrollCountSpinBox.value
|
editingModelData.scrollCount = scrollCountSpinBox.value
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
editingModel.append(textTextField.value,
|
editingModel.append(textTextField.value,
|
||||||
|
@ -49,6 +50,11 @@ Dialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDiscarded: {
|
||||||
|
editingModel.remove(popup.editingModelData.index)
|
||||||
|
popup.close()
|
||||||
|
}
|
||||||
|
|
||||||
contentItem: Flickable {
|
contentItem: Flickable {
|
||||||
|
|
||||||
implicitHeight: dataFieldsGridLayout.height
|
implicitHeight: dataFieldsGridLayout.height
|
||||||
|
@ -163,21 +169,22 @@ Dialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit(model) {
|
function edit(model, modelData) {
|
||||||
editingModel = model
|
editingModel = model
|
||||||
|
editingModelData = modelData
|
||||||
editing = true
|
editing = true
|
||||||
|
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
activeSwitch.checked = editingModel.active
|
activeSwitch.checked = editingModelData.active
|
||||||
textTextField.value = editingModel.text
|
textTextField.value = editingModelData.text
|
||||||
runtimeSpinBox.value = editingModel.runtime
|
runtimeSpinBox.value = editingModelData.runtime
|
||||||
colorColorPicker.value = editingModel.color
|
colorColorPicker.value = editingModelData.color
|
||||||
alignmentComboBox.currentIndex = editingModel.alignment
|
alignmentComboBox.currentIndex = editingModelData.alignment
|
||||||
scrollSwitch.checked = editingModel.scroll
|
scrollSwitch.checked = editingModelData.scroll
|
||||||
scrollDirectionComboBox.currentIndex = editingModel.scrollDirection
|
scrollDirectionComboBox.currentIndex = editingModelData.scrollDirection
|
||||||
scrollSpeedSpinBox.value = editingModel.scrollSpeed
|
scrollSpeedSpinBox.value = editingModelData.scrollSpeed
|
||||||
scrollCountSpinBox.value = editingModel.scrollCount
|
scrollCountSpinBox.value = editingModelData.scrollCount
|
||||||
|
|
||||||
open()
|
open()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 76e457593e889885fd410fdbcdd659706a1eceb8
|
|
Loading…
Reference in a new issue