Commit 78d3dde7 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Almost finished with struct tree viewer

parent 9f0be9f4
...@@ -41,8 +41,14 @@ public: ...@@ -41,8 +41,14 @@ public:
void SetStruct( const CVAStruct& oStruct ) void SetStruct( const CVAStruct& oStruct )
{ {
QStandardItem *rootNode = m_pModel->invisibleRootItem(); m_pModel->clear();
QStandardItem* item = new QStandardItem; BuildStandardItemFromVAStruct( oStruct, m_pModel->invisibleRootItem() );
return;
CVAStruct oMyStruct;
oMyStruct[ "hi" ] = "wo!?!";
/*rootNode->appendRow( BuildStandardItemFromVAStruct( oMyStruct ) );
//return;
QList<QStandardItem *> qlDescriptors; QList<QStandardItem *> qlDescriptors;
qlDescriptors << new QStandardItem( "Name" ); qlDescriptors << new QStandardItem( "Name" );
...@@ -51,7 +57,7 @@ public: ...@@ -51,7 +57,7 @@ public:
rootNode->appendRow( qlDescriptors ); rootNode->appendRow( qlDescriptors );
QList<QStandardItem *> qlDescriptor2; QList<QStandardItem *> qlDescriptor2;
qlDescriptor2 << new QStandardItem( "Name" ); qlDescriptor2 << new QStandardItem( "weiteres" );
rootNode->appendRow( qlDescriptor2 ); rootNode->appendRow( qlDescriptor2 );
QList<QStandardItem *> qlDescriptor3; QList<QStandardItem *> qlDescriptor3;
...@@ -70,6 +76,7 @@ public: ...@@ -70,6 +76,7 @@ public:
qlDescriptor3.first()->appendRow( qlDescriptor4 ); qlDescriptor3.first()->appendRow( qlDescriptor4 );
qlDescriptor3.first()->appendRow( qlDescriptor5 ); qlDescriptor3.first()->appendRow( qlDescriptor5 );
*/
}; };
inline ~RedstartSessionDetailsTreeView() {}; inline ~RedstartSessionDetailsTreeView() {};
......
...@@ -19,59 +19,63 @@ ...@@ -19,59 +19,63 @@
#include <cassert> #include <cassert>
inline void ConvertVAStructToStandardItem( const CVAStruct& oStruct, QStandardItem* pItem ) //! Builds a standard item from a VA struct
/**
* Creates items dynamically.
*/
inline void BuildStandardItemFromVAStruct( const CVAStruct& oStruct, QStandardItem* pRootNode )
{ {
assert( pItem != nullptr );
// QList< QStandardItem* > qlpItems;
CVAStruct::const_iterator cit = oStruct.Begin(); CVAStruct::const_iterator cit = oStruct.Begin();
/*
while( cit != oStruct.End() ) while( cit != oStruct.End() )
{ {
const QString sKey( cit->first.c_str() ); const QString sKey( cit->first.c_str() );
const CVAStructValue& oValue( cit->second ); const CVAStructValue& oValue( cit->second );
cit++; cit++;
if( oValue.IsStruct() ) QList< QStandardItem* > pItemList;
{ pItemList << new QStandardItem( sKey );
QStandardItem* pNewItem = new QStandardItem;
pItem->appendColumn( pNewItem );
ConvertVAStructToStandardItem( oValue, pNewItem );
}
switch( oValue.GetDatatype() ) switch( oValue.GetDatatype() )
{ {
case CVAStructValue::BOOL: case CVAStructValue::BOOL:
{ {
pItem->appendColumn()[ sKey ] = bool( oValue ); pItemList << new QStandardItem( QVariant( bool( oValue ) ).toString() );
pItemList << new QStandardItem( "Bool" );
break; break;
} }
case CVAStructValue::INT: case CVAStructValue::INT:
{ {
oHash[ sKey ] = int( oValue ); pItemList << new QStandardItem( QVariant( int( oValue ) ).toString() );
pItemList << new QStandardItem( "Int" );
break; break;
} }
case CVAStructValue::DOUBLE: case CVAStructValue::DOUBLE:
{ {
oHash[ sKey ] = double( oValue ); pItemList << new QStandardItem( QVariant( double( oValue ) ).toString() );
pItemList << new QStandardItem( "Double" );
break; break;
} }
case CVAStructValue::STRING: case CVAStructValue::STRING:
{ {
oHash[ sKey ] = QString( std::string( oValue ).c_str() ); pItemList << new QStandardItem( QString( std::string( oValue ).c_str() ) );
pItemList << new QStandardItem( "String" );
break; break;
} }
case CVAStructValue::DATA: case CVAStructValue::DATA:
{ {
oHash[ sKey ] = QByteArray( ( const char* ) oValue.GetData(), oValue.GetDataSize() ); pItemList << new QStandardItem( QVariant( int( oValue.GetDataSize() ) ).toString() );
pItemList << new QStandardItem( "Bytes" );
break; break;
} }
case CVAStructValue::STRUCT:
{
BuildStandardItemFromVAStruct( oValue, pItemList.first() );
} }
} }
pItem->appendColumn( qlpItems ); pRootNode->appendRow( pItemList );
*/ }
}; };
inline QVariantHash ConvertVAStructToQHash( const CVAStruct& oStruct ) inline QVariantHash ConvertVAStructToQHash( const CVAStruct& oStruct )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment