Companion fix global and special functions context menu (#7885)

This commit is contained in:
Neil Horne
2020-09-06 10:58:33 +02:00
committed by GitHub
parent cf72dd28bc
commit 3323597a8a
+6 -6
View File
@@ -605,13 +605,13 @@ void CustomFunctionsPanel::cmPaste()
void CustomFunctionsPanel::cmDelete() void CustomFunctionsPanel::cmDelete()
{ {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete Special Function. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete Function. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return; return;
memmove(&functions[selectedIndex], &functions[selectedIndex + 1], (CPN_MAX_SPECIAL_FUNCTIONS - (selectedIndex + 1)) * sizeof(CustomFunctionData)); memmove(&functions[selectedIndex], &functions[selectedIndex + 1], (CPN_MAX_SPECIAL_FUNCTIONS - (selectedIndex + 1)) * sizeof(CustomFunctionData));
functions[fswCapability - 1].clear(); functions[fswCapability - 1].clear();
for (int i = selectedIndex; i < (fswCapability - 1); i++) { for (int i = selectedIndex; i < fswCapability; i++) {
resetCBsAndRefresh(i); resetCBsAndRefresh(i);
} }
emit modified(); emit modified();
@@ -748,7 +748,7 @@ void CustomFunctionsPanel::cmMoveDown()
void CustomFunctionsPanel::cmClear(bool prompt) void CustomFunctionsPanel::cmClear(bool prompt)
{ {
if (prompt) { if (prompt) {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Special Function. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Function. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return; return;
} }
@@ -759,7 +759,7 @@ void CustomFunctionsPanel::cmClear(bool prompt)
void CustomFunctionsPanel::cmClearAll() void CustomFunctionsPanel::cmClearAll()
{ {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Special Functions. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Functions. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return; return;
for (int i = 0; i < fswCapability; i++) { for (int i = 0; i < fswCapability; i++) {
@@ -774,7 +774,7 @@ void CustomFunctionsPanel::cmInsert()
memmove(&functions[selectedIndex + 1], &functions[selectedIndex], (CPN_MAX_SPECIAL_FUNCTIONS - (selectedIndex + 1)) * sizeof(CustomFunctionData)); memmove(&functions[selectedIndex + 1], &functions[selectedIndex], (CPN_MAX_SPECIAL_FUNCTIONS - (selectedIndex + 1)) * sizeof(CustomFunctionData));
functions[selectedIndex].clear(); functions[selectedIndex].clear();
for (int i = selectedIndex; i < (fswCapability - 1); i++) { for (int i = selectedIndex; i < fswCapability; i++) {
resetCBsAndRefresh(i); resetCBsAndRefresh(i);
} }
} }
@@ -818,7 +818,7 @@ bool CustomFunctionsPanel::hasClipboardData(QByteArray * data) const
bool CustomFunctionsPanel::insertAllowed() const bool CustomFunctionsPanel::insertAllowed() const
{ {
return ((selectedIndex < fswCapability - 1) && (model->curves[fswCapability - 1].isEmpty())); return ((selectedIndex < fswCapability - 1) && (functions[fswCapability - 1].isEmpty()));
} }
bool CustomFunctionsPanel::moveDownAllowed() const bool CustomFunctionsPanel::moveDownAllowed() const