diff --git a/src/controls/LevelingSensor/QskLevelingSensorSkinlet.cpp b/src/controls/LevelingSensor/QskLevelingSensorSkinlet.cpp index dae31e2f..51102fb5 100644 --- a/src/controls/LevelingSensor/QskLevelingSensorSkinlet.cpp +++ b/src/controls/LevelingSensor/QskLevelingSensorSkinlet.cpp @@ -406,7 +406,7 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode( const QskSkinnable* const skinnable, const quint8 nodeRole, QSGNode* const node ) const { const auto* const sensor = static_cast< const Q* >( skinnable ); - + switch ( static_cast< R >( nodeRole ) ) { case OuterDisk: diff --git a/src/controls/LevelingSensor/QskSGNodeUtility.h b/src/controls/LevelingSensor/QskSGNodeUtility.h index 31ea9c5c..399e7c84 100644 --- a/src/controls/LevelingSensor/QskSGNodeUtility.h +++ b/src/controls/LevelingSensor/QskSGNodeUtility.h @@ -3,64 +3,36 @@ #include namespace QskSGNode -{ - enum AppendMode : bool { - Sequential = false, - Recursive = true - }; - - namespace detail +{ + enum AppendMode { - template< AppendMode Mode, typename... Ts > - struct append; - - template<> - struct append - { - static void nodes( QSGNode* root ) - { - } - }; - - template<> - struct append - { - static void nodes( QSGNode* root ) - { - } - }; - - template< typename Child, typename... Children > - struct append< AppendMode::Recursive, Child, Children... > - { - static void nodes( QSGNode* root ) - { - auto* const child = new Child; - root->appendChildNode( child ); - append< AppendMode::Recursive, Children... >::nodes( child ); - } - }; - - template< typename Child, typename... Children > - struct append< AppendMode::Sequential, Child, Children... > - { - static void nodes( QSGNode* root ) - { - auto* const child = new Child; - root->appendChildNode( child ); - append< AppendMode::Sequential, Children... >::nodes( root ); - } - }; - } + Sequential, + Recursive + }; template< AppendMode mode, typename Root, typename... Children > inline Q_REQUIRED_RESULT Root* ensureNodes( QSGNode* root = nullptr ) { if ( root == nullptr ) { - root = new std::remove_const_t(); - detail::append< mode, Children... >::nodes( root ); + root = new Root; } - return static_cast(root); + + if constexpr ( mode == Recursive ) + { + QSGNode* current = root; + ( + [ & ]( QSGNode* const child ) { + current->appendChildNode( child ); + current = child; + }( new Children ), + ... ); + } + else + { + ( root->appendChildNode( new Children ), ... ); + } + + return static_cast< Root* >( root ); } } \ No newline at end of file