diff --git a/companion/src/labels.cpp b/companion/src/labels.cpp index f994da7b0..6cb4ef92f 100644 --- a/companion/src/labels.cpp +++ b/companion/src/labels.cpp @@ -60,6 +60,8 @@ bool LabelsModel::setData(const QModelIndex &index, const QVariant &value, int r this->index(index.row(), 0)); if(selectedModel != -1 && modelsChanged) emit modelChanged(selectedModel); + } else { + emit renameFault(tr("Unable to rename \"%1\" to \"%2\" the label already exists").arg(replFrom).arg(replTo)); } return true; } diff --git a/companion/src/labels.h b/companion/src/labels.h index e39dda467..3d836ba8d 100644 --- a/companion/src/labels.h +++ b/companion/src/labels.h @@ -45,6 +45,7 @@ private slots: signals: void modelChanged(int index); + void renameFault(QString msg); private: QItemSelectionModel *modelsSelection; diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 8d06177ca..745c198b4 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -509,6 +509,7 @@ void MdiChild::initModelsList() labelsListModel = new LabelsModel(ui->modelsList->selectionModel(), &radioData, this); connect(labelsListModel, &LabelsModel::modelChanged, this, &MdiChild::modelLabelsChanged); + connect(labelsListModel, &LabelsModel::renameFault, this, &MdiChild::labelRenameFault); ui->lstLabels->setModel(labelsListModel); ui->lstLabels->setSelectionMode(QAbstractItemView::SingleSelection); ui->lstLabels->setDragEnabled(true); @@ -1716,6 +1717,11 @@ void MdiChild::modelLabelsChanged() refresh(); } +void MdiChild::labelRenameFault(QString msg) +{ + QMessageBox::warning(this, CPN_STR_TTL_WARNING, msg); +} + unsigned MdiChild::saveModels(const QVector modelIndices) { unsigned saves = 0; diff --git a/companion/src/mdichild.h b/companion/src/mdichild.h index 379eed754..934d09548 100644 --- a/companion/src/mdichild.h +++ b/companion/src/mdichild.h @@ -141,6 +141,7 @@ class MdiChild : public QWidget void labelAdd(); void labelDelete(); void modelLabelsChanged(); + void labelRenameFault(QString msg); void wizardEdit(); void modelDuplicate();