From 0e2c1bdae4d1d75b61c4c4549b275d505d5ddb7b Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Fri, 28 Jan 2022 18:19:30 +0100 Subject: [PATCH] Fixing bugs related to property changes in history with enum, object & list properties --- LogarithmPlotter/i18n/lp_de.ts | 10 ++--- LogarithmPlotter/i18n/lp_en.ts | 10 ++--- LogarithmPlotter/i18n/lp_es.ts | 10 ++--- LogarithmPlotter/i18n/lp_fr.ts | 12 +++--- LogarithmPlotter/i18n/lp_hu.ts | 10 ++--- LogarithmPlotter/i18n/lp_nb_NO.ts | 10 ++--- LogarithmPlotter/i18n/lp_template.ts | 10 ++--- .../ObjectLists/EditorDialog.qml | 2 +- .../ad5001/LogarithmPlotter/js/historylib.js | 41 +++++++++++++++---- 9 files changed, 69 insertions(+), 46 deletions(-) diff --git a/LogarithmPlotter/i18n/lp_de.ts b/LogarithmPlotter/i18n/lp_de.ts index 6680f5e..24a7e33 100644 --- a/LogarithmPlotter/i18n/lp_de.ts +++ b/LogarithmPlotter/i18n/lp_de.ts @@ -569,27 +569,27 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" historylib - + New %1 %2 created. Neu %1 %2 erstellt. - + %1 %2 deleted. %1 %2 gelöscht. - + %1 of %2 %3 changed from "%4" to "%5". %1 von %2 %3 wurde von "%4" auf "%5" geändert. - + %1 %2 shown. %1 %2 angezeigt. - + %1 %2 hidden. %1 %2 ausgeblendet. diff --git a/LogarithmPlotter/i18n/lp_en.ts b/LogarithmPlotter/i18n/lp_en.ts index 70d8d59..416f045 100644 --- a/LogarithmPlotter/i18n/lp_en.ts +++ b/LogarithmPlotter/i18n/lp_en.ts @@ -569,27 +569,27 @@ These settings can be changed at any time from the "Settings" menu. historylib - + New %1 %2 created. New %1 %2 created. - + %1 %2 deleted. %1 %2 deleted. - + %1 of %2 %3 changed from "%4" to "%5". %1 of %2 %3 changed from "%4" to "%5". - + %1 %2 shown. %1 %2 shown. - + %1 %2 hidden. %1 %2 hidden. diff --git a/LogarithmPlotter/i18n/lp_es.ts b/LogarithmPlotter/i18n/lp_es.ts index 1d9e2fa..6db6065 100644 --- a/LogarithmPlotter/i18n/lp_es.ts +++ b/LogarithmPlotter/i18n/lp_es.ts @@ -568,27 +568,27 @@ These settings can be changed at any time from the "Settings" menu. historylib - + New %1 %2 created. - + %1 %2 deleted. - + %1 of %2 %3 changed from "%4" to "%5". - + %1 %2 shown. - + %1 %2 hidden. diff --git a/LogarithmPlotter/i18n/lp_fr.ts b/LogarithmPlotter/i18n/lp_fr.ts index 47f3ebd..aec7f5f 100644 --- a/LogarithmPlotter/i18n/lp_fr.ts +++ b/LogarithmPlotter/i18n/lp_fr.ts @@ -578,27 +578,27 @@ These settings can always be changed at any time from the "Settings" m historylib - + New %1 %2 created. - Nouveau %1 %2 créé(e). + Nouvel objet %1 %2 créé. - + %1 %2 deleted. %1 %2 supprimé(e). - + %1 of %2 %3 changed from "%4" to "%5". %1 de %2 %3 modifiée de "%4" à "%5". - + %1 %2 shown. %1 %2 affiché(e). - + %1 %2 hidden. %1 %2 cachée(e). diff --git a/LogarithmPlotter/i18n/lp_hu.ts b/LogarithmPlotter/i18n/lp_hu.ts index 2367bb3..87212eb 100644 --- a/LogarithmPlotter/i18n/lp_hu.ts +++ b/LogarithmPlotter/i18n/lp_hu.ts @@ -569,27 +569,27 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. historylib - + New %1 %2 created. Új %1 %2 létrehozva. - + %1 %2 deleted. %1 %2 törölve. - + %1 of %2 %3 changed from "%4" to "%5". %1/%2 %3 megváltozott. Régi érték: %4, új érték: %5. - + %1 %2 shown. %1 %2 megjelenítve. - + %1 %2 hidden. %1 %2 rejtve. diff --git a/LogarithmPlotter/i18n/lp_nb_NO.ts b/LogarithmPlotter/i18n/lp_nb_NO.ts index 36b3a8e..84d7150 100644 --- a/LogarithmPlotter/i18n/lp_nb_NO.ts +++ b/LogarithmPlotter/i18n/lp_nb_NO.ts @@ -569,27 +569,27 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. historylib - + New %1 %2 created. Ny %1 %2 opprettet. - + %1 %2 deleted. %1 %2 slettet. - + %1 of %2 %3 changed from "%4" to "%5". %1 av %2 %3 endret fra «%4» til «%5». - + %1 %2 shown. %1 %2 vist. - + %1 %2 hidden. %1 %2 skjult. diff --git a/LogarithmPlotter/i18n/lp_template.ts b/LogarithmPlotter/i18n/lp_template.ts index b0bd0ea..2bef736 100644 --- a/LogarithmPlotter/i18n/lp_template.ts +++ b/LogarithmPlotter/i18n/lp_template.ts @@ -568,27 +568,27 @@ These settings can be changed at any time from the "Settings" menu. historylib - + New %1 %2 created. - + %1 %2 deleted. - + %1 of %2 %3 changed from "%4" to "%5". - + %1 %2 shown. - + %1 %2 hidden. diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/EditorDialog.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/EditorDialog.qml index 53d566e..13592aa 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/EditorDialog.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/EditorDialog.qml @@ -33,7 +33,7 @@ D.Dialog { property var obj: Objects.currentObjects[objType][objIndex] property QtObject editingRow: QtObject{} property var objectLists - title: `LogarithmPlotter` + title: "LogarithmPlotter" width: 350 height: 400 diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/historylib.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/historylib.js index 4f957df..ea27b13 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/historylib.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/historylib.js @@ -21,6 +21,7 @@ .pragma library .import "objects.js" as Objects +.import "parameters.js" as P .import "objs/common.js" as Common .import "utils.js" as Utils .import "mathlib.js" as MathLib @@ -103,14 +104,15 @@ class EditedProperty extends Action { constructor(targetName = "", targetType = "Point", targetProperty = "visible", previousValue = false, newValue = true, valueIsExpressionNeedingImport = false) { super(targetName, targetType) this.targetProperty = targetProperty - this.targetPropertyReadable = Utils.camelCase2readable(this.targetProperty) + this.targetPropertyReadable = qsTranslate("prop", this.targetProperty) this.previousValue = previousValue this.newValue = newValue + this.propertyType = Objects.types[targetType].properties()[targetProperty] if(valueIsExpressionNeedingImport) { - if(targetType == "Expression") { + if(propertyType == "Expression") { this.previousValue = new MathLib.Expression(this.previousValue); this.newValue = new MathLib.Expression(this.newValue); - } else if(targetType == "Domain") { + } else if(propertyType == "Domain") { this.previousValue = MathLib.parseDomain(this.previousValue); this.newValue = MathLib.parseDomain(this.newValue); } else { @@ -140,12 +142,33 @@ class EditedProperty extends Action { } getReadableString() { - var prev = this.previousValue == null ? "null" : this.previousValue.toString() - var next = this.newValue == null ? "null" : this.newValue.toString() - if(prev == "[object Object]") // Oh no! - prev = JSON.stringify(this.previousValue).replace("'", "\\'").replace('"', "'") - if(next == "[object Object]") // Oh no! - next = JSON.stringify(this.previousValue).replace("'", "\\'").replace('"', "'") + let prev = ""; + let next = ""; + if(this.propertyType instanceof Object) { + console.log(this.propertyType.type) + switch(this.propertyType.type) { + case "Enum": + console.log(this.propertyType.translatedValues, this.previousValue, this.propertyType.values.indexOf(this.previousValue)) + prev = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.previousValue)] + next = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.newValue)] + break; + case "ObjectType": + prev = this.previousValue.name + next = this.newValue.name + break; + case "List": + prev = this.previousValue.join(",") + next = this.newValue.name.join(",") + break; + case "Dict": + prev = JSON.stringify(this.previousValue).replace("'", "\\'").replace('"', "'") + next = JSON.stringify(this.newValue).replace("'", "\\'").replace('"', "'") + break; + } + } else { + prev = this.previousValue == null ? "null" : this.previousValue.toString() + next = this.newValue == null ? "null" : this.newValue.toString() + } return qsTr('%1 of %2 %3 changed from "%4" to "%5".') .arg(this.targetPropertyReadable) .arg(Objects.types[this.targetType].displayType())