Fix delete input
This commit is contained in:
@@ -351,7 +351,7 @@ void InputsPanel::expoOpen(QListWidgetItem *item)
|
|||||||
if (!item)
|
if (!item)
|
||||||
item = ExposlistWidget->currentItem();
|
item = ExposlistWidget->currentItem();
|
||||||
|
|
||||||
if (item == nullptr)
|
if (item == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int idx = item->data(Qt::UserRole).toByteArray().at(0);
|
int idx = item->data(Qt::UserRole).toByteArray().at(0);
|
||||||
@@ -372,7 +372,7 @@ void InputsPanel::expoOpen(QListWidgetItem *item)
|
|||||||
void InputsPanel::expoAdd()
|
void InputsPanel::expoAdd()
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = ExposlistWidget->currentItem();
|
QListWidgetItem *item = ExposlistWidget->currentItem();
|
||||||
if (item == nullptr)
|
if (item == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int index = item->data(Qt::UserRole).toByteArray().at(0);
|
int index = item->data(Qt::UserRole).toByteArray().at(0);
|
||||||
@@ -580,13 +580,15 @@ bool InputsPanel::cmInputMoveUpAllowed() const
|
|||||||
|
|
||||||
void InputsPanel::cmInputClear()
|
void InputsPanel::cmInputClear()
|
||||||
{
|
{
|
||||||
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all lines for the selected Inputs. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all lines for the selected Input. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = CPN_MAX_EXPOS - 1; i >= 0; i--) {
|
for (int i = CPN_MAX_EXPOS - 1; i >= 0; i--) {
|
||||||
ExpoData *ed = &model->expoData[i];
|
ExpoData *ed = &model->expoData[i];
|
||||||
if ((int)ed->chn == inputIdx)
|
if (!ed->isEmpty()) {
|
||||||
model->removeInput(i);
|
if ((int)ed->chn == inputIdx)
|
||||||
|
model->removeInput(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, inputIdx);
|
model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, inputIdx);
|
||||||
update();
|
update();
|
||||||
@@ -596,15 +598,17 @@ void InputsPanel::cmInputClear()
|
|||||||
|
|
||||||
void InputsPanel::cmInputDelete()
|
void InputsPanel::cmInputDelete()
|
||||||
{
|
{
|
||||||
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete all lines for the selected Inputs. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete all lines for the selected Input. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < CPN_MAX_EXPOS; i++) {
|
for (int i = CPN_MAX_EXPOS - 1; i >= 0; i--) {
|
||||||
ExpoData *ed = &model->expoData[i];
|
ExpoData *ed = &model->expoData[i];
|
||||||
if ((int)ed->chn == inputIdx)
|
if (!ed->isEmpty()) {
|
||||||
model->removeInput(i);
|
if ((int)ed->chn == inputIdx)
|
||||||
else if ((int)ed->chn > inputIdx)
|
model->removeInput(i);
|
||||||
ed->chn--;
|
else if ((int)ed->chn > inputIdx)
|
||||||
|
ed->chn--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = inputIdx; i < inputsCount; i++) {
|
for (int i = inputIdx; i < inputsCount; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user