Gui: Notifications Framework - accept more notifier types

=========================================================

Extends notifier types to Gui::Document, App::Document, Gui::ViewProviderDocumentObject.

This allows to pass these objects as notifiers, and the framework gets the right string
from the Label or FullLabel as appropriate.
This commit is contained in:
Abdullah Tahiri
2023-05-24 17:47:45 +02:00
committed by abdullahtahiriyo
parent 367a0a7277
commit 2a3fe4c628

View File

@@ -166,6 +166,21 @@ inline void Gui::Notify(TNotifier && notifier, TCaption && caption, TMessage &&
Base::IntendedRecipient::Developer,
Base::ContentType::Untranslated>(notifier->getFullLabel(), msg.c_str());
}
else if constexpr( std::is_base_of_v<Gui::ViewProviderDocumentObject, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type,
Base::IntendedRecipient::Developer,
Base::ContentType::Untranslated>(notifier->getObject()->getFullLabel(), msg.c_str());
}
else if constexpr( std::is_base_of_v<Gui::Document, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type,
Base::IntendedRecipient::Developer,
Base::ContentType::Untranslated>(notifier->getDocument()->Label.getStrValue(), msg.c_str());
}
else if constexpr( std::is_base_of_v<App::Document, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type,
Base::IntendedRecipient::Developer,
Base::ContentType::Untranslated>(notifier->Label.getStrValue(), msg.c_str());
}
else {
Base::Console().Send<type,
Base::IntendedRecipient::Developer,
@@ -219,6 +234,15 @@ inline void Gui::Notify(TNotifier && notifier, TCaption && caption, TMessage &&
if constexpr( std::is_base_of_v<App::DocumentObject, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type, recipient, content>(notifier->getFullLabel(), msg.toUtf8());
}
else if constexpr( std::is_base_of_v<Gui::ViewProviderDocumentObject, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type, recipient, content>(notifier->getObject()->getFullLabel(), msg.toUtf8());
}
else if constexpr( std::is_base_of_v<Gui::Document, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type, recipient, content>(notifier->getDocument()->Label.getStrValue(), msg.toUtf8());
}
else if constexpr( std::is_base_of_v<App::Document, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type, recipient, content>(notifier->Label.getStrValue(), msg.toUtf8());
}
else {
Base::Console().Send<type, recipient, content>(notifier, msg.toUtf8());
}
@@ -230,6 +254,15 @@ inline void Gui::Notify(TNotifier && notifier, TCaption && caption, TMessage &&
if constexpr( std::is_base_of_v<App::DocumentObject, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type, recipient, content>(notifier->getFullLabel(), msg.c_str());
}
else if constexpr( std::is_base_of_v<Gui::ViewProviderDocumentObject, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type, recipient, content>(notifier->getObject()->getFullLabel(), msg.c_str());
}
else if constexpr( std::is_base_of_v<Gui::Document, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type, recipient, content>(notifier->getDocument()->Label.getStrValue(), msg.c_str());
}
else if constexpr( std::is_base_of_v<App::Document, std::remove_pointer_t<typename std::decay<TNotifier>::type>> ) {
Base::Console().Send<type, recipient, content>(notifier->Label.getStrValue(), msg.c_str());
}
else {
Base::Console().Send<type, recipient, content>(notifier, msg.c_str());
}