QString ScriptableContext::render( const QObjectList &list ) { NodeList nodeList; QListIterator<QObject *> it( list ); while ( it.hasNext() ) { Node *node = qobject_cast<Node*>( it.next() ); if ( node ) nodeList << node; } QString ret; QTextStream t( &ret ); OutputStream stream( &t ); nodeList.render( &stream, m_c ); return ret; }
void BlockNode::render( OutputStream *stream, Context *c ) { QVariant &variant = c->renderContext()->data( BLOCK_CONTEXT_KEY ); BlockContext blockContext = variant.value<BlockContext>(); c->push(); if ( blockContext.isEmpty() ) { m_context = c; m_stream = stream; c->insert( QLatin1String( "block" ), QVariant::fromValue( static_cast<QObject *>( this ) ) ); m_list.render( stream, c ); m_stream = 0; } else { BlockNode *block = blockContext.pop( m_name ); variant.setValue( blockContext ); BlockNode *push = block; if ( !block ) block = this; // BIC Make const when render() is const. NodeList list = block->m_list; block = new BlockNode( block->m_name, 0 ); block->setNodeList( list ); block->m_context = c; block->m_stream = stream; c->insert( QLatin1String( "block" ), QVariant::fromValue( static_cast<QObject *>( block ) ) ); list.render( stream, c ); delete block; if ( push ) { blockContext.push( m_name, push ); variant.setValue( blockContext ); } } c->pop(); }