feat(cpn): Prompt/option to insert if pasting onto existing model (#1976)
* Option to insert if pasting onto existing model * Change button from Continue to Overwrite and message prompt wording
This commit is contained in:
@@ -1046,10 +1046,32 @@ void MdiChild::pasteModelData(const QMimeData * mimeData, const QModelIndex row,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // pasting on top of a slot
|
else { // pasting on top of a slot
|
||||||
if (!radioData.models[modelIdx].isEmpty() && !deletesList.contains(modelIdx))
|
if (!radioData.models[modelIdx].isEmpty() && !deletesList.contains(modelIdx)) {
|
||||||
ok = askQuestion(tr("You are replacing an existing model, are you sure?")) == QMessageBox::Yes;
|
QMessageBox msgBox;
|
||||||
if (ok)
|
msgBox.setWindowTitle(CPN_STR_APP_NAME);
|
||||||
radioData.models[modelIdx] = modelsList[i];
|
msgBox.setIcon(QMessageBox::Warning);
|
||||||
|
msgBox.setText(tr("Model already exists! Do you want to overwrite it or insert into a new slot?"));
|
||||||
|
QPushButton *overwriteButton = msgBox.addButton(tr("Overwrite"),QMessageBox::ActionRole);
|
||||||
|
QPushButton *insertButton = msgBox.addButton(tr("Insert"),QMessageBox::ActionRole);
|
||||||
|
QPushButton *cancelButton = msgBox.addButton(QMessageBox::Cancel);
|
||||||
|
|
||||||
|
msgBox.exec();
|
||||||
|
|
||||||
|
if (msgBox.clickedButton() == overwriteButton) {
|
||||||
|
radioData.models[modelIdx] = modelsList[i];
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
else if (msgBox.clickedButton() == insertButton) {
|
||||||
|
ok = insertModelRows(modelIdx, 1);
|
||||||
|
if (ok) {
|
||||||
|
radioData.models[modelIdx] = modelsList[i];
|
||||||
|
++inserts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user