From 14b6a1e6aaf0e0e5f361c03de5b96a475efe50b0 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 22 Feb 2020 18:06:51 +0100 Subject: [PATCH] UI-Base: diagnostic self-ID for any "tangible" UI-Element low hanging fruit, and quite helpful e.g. when a Diff flounders, since it will automatically show up in the exception message. --- src/stage/model/tangible.cpp | 63 ++++++++++++++++++++-------------- src/stage/model/tangible.hpp | 7 ++-- wiki/thinkPad.ichthyo.mm | 66 +++++++++++++++++++++++++++++------- 3 files changed, 97 insertions(+), 39 deletions(-) diff --git a/src/stage/model/tangible.cpp b/src/stage/model/tangible.cpp index cd227271f..e832fdb5b 100644 --- a/src/stage/model/tangible.cpp +++ b/src/stage/model/tangible.cpp @@ -35,6 +35,7 @@ #include "stage/model/controller.hpp" #include "include/ui-protocol.hpp" #include "lib/diff/gen-node.hpp" +#include "lib/meta/util.hpp" namespace stage { @@ -46,6 +47,18 @@ namespace model { + /** diagnostic representation. + * @note used in exceptions to indicate the origin. + */ + Tangible::operator string() const + { + return lib::meta::typeStr (this) + + "(" + + string{this->getID()} + + ")"; + } + + /** invoke the generic reset hook * @note the actual subclass has to override the doReset() hook * to perform the actual clean-up work. @@ -59,10 +72,10 @@ namespace model { */ void Tangible::reset() - { - if (this->doReset()) - uiBus_.note (GenNode{string{MARK_reset}, true}); - } + { + if (this->doReset()) + uiBus_.note (GenNode{string{MARK_reset}, true}); + } /** invoke the hook to clear error markers @@ -81,10 +94,10 @@ namespace model { */ void Tangible::clearErr() - { - if (this->doClearErr()) - uiBus_.note (GenNode{string{MARK_clearErr}, true}); - } + { + if (this->doClearErr()) + uiBus_.note (GenNode{string{MARK_clearErr}, true}); + } /** invoke the hook to clear notification messages @@ -92,10 +105,10 @@ namespace model { */ void Tangible::clearMsg() - { - if (this->doClearMsg()) - uiBus_.note (GenNode{string{MARK_clearMsg}, true}); - } + { + if (this->doClearMsg()) + uiBus_.note (GenNode{string{MARK_clearMsg}, true}); + } /** highlight the element visually to catch the user's attention @@ -104,9 +117,9 @@ namespace model { */ void Tangible::markFlash() - { - this->doFlash(); - } + { + this->doFlash(); + } /** push a notification (or warning) message to the element. @@ -124,10 +137,10 @@ namespace model { */ void Tangible::markMsg (string message) - { - if (this->doMsg (message)) - uiBus_.note (GenNode{string{MARK_Message}, message}); - } + { + if (this->doMsg (message)) + uiBus_.note (GenNode{string{MARK_Message}, message}); + } /** push an error state tag to the element @@ -135,10 +148,10 @@ namespace model { */ void Tangible::markErr (string error) - { - if (this->doErr (error)) - uiBus_.note (GenNode{string{MARK_Error}, error}); - } + { + if (this->doErr (error)) + uiBus_.note (GenNode{string{MARK_Error}, error}); + } /** @@ -156,7 +169,7 @@ namespace model { void Tangible::slotExpand() { - if (this->doExpand(true)) + if (this->doExpand (true)) uiBus_.note (GenNode{string{MARK_expand}, true}); } @@ -168,7 +181,7 @@ namespace model { void Tangible::slotCollapse() { - if (this->doExpand(false)) + if (this->doExpand (false)) uiBus_.note (GenNode{string{MARK_expand}, false}); } diff --git a/src/stage/model/tangible.hpp b/src/stage/model/tangible.hpp index f53ab2429..a4b264038 100644 --- a/src/stage/model/tangible.hpp +++ b/src/stage/model/tangible.hpp @@ -189,8 +189,11 @@ namespace model { public: virtual ~Tangible(); ///< this is an interface - operator ID() const { return uiBus_.getID();} - operator LuidH() const { return uiBus_.getID().getHash(); } + operator ID() const { return uiBus_.getID();} + operator LuidH() const { return uiBus_.getID().getHash(); } + + operator string() const; + ID getID() const { return uiBus_.getID();} void reset(); void clearMsg(); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index da38d2c27..c8d7bd39c 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -28992,7 +28992,7 @@ - + @@ -29153,9 +29153,10 @@ - + + - + @@ -29369,7 +29370,7 @@ - + @@ -29427,7 +29428,7 @@ - + @@ -29465,7 +29466,7 @@ - + @@ -29565,7 +29566,7 @@ - + @@ -31455,7 +31456,7 @@ - + @@ -31471,7 +31472,7 @@ - + @@ -31504,7 +31505,7 @@ - + @@ -31546,7 +31547,7 @@ - + @@ -31605,6 +31606,31 @@ + + + + + + + + +

+ »Tangible« : Basis +

+ + +
+ + + + + + + + + + +
@@ -37620,7 +37646,7 @@
- + @@ -41394,6 +41420,22 @@ + + + + + + + + +

+ es ist wohl nicht ein spezieller Diff. Es tritt sogar auf, wenn man zweimal den gleichen Diff schickt +

+ + +
+
+