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

Almost finished with struct tree viewer

parent 9f0be9f4
......@@ -34,15 +34,21 @@ public:
m_pModel = new RedstartSessionDetailModel();
this->setModel( m_pModel );
m_pModel->setHorizontalHeaderLabels( QStringList() << "Key" << "Value" << "Type" );
//setEditTriggers( QAbstractItemView::NoEditTriggers );
//setSelectionMode( QAbstractItemView::SingleSelection );
};
void SetStruct( const CVAStruct& oStruct )
{
QStandardItem *rootNode = m_pModel->invisibleRootItem();
QStandardItem* item = new QStandardItem;
m_pModel->clear();
BuildStandardItemFromVAStruct( oStruct, m_pModel->invisibleRootItem() );
return;
CVAStruct oMyStruct;
oMyStruct[ "hi" ] = "wo!?!";
/*rootNode->appendRow( BuildStandardItemFromVAStruct( oMyStruct ) );
//return;
QList<QStandardItem *> qlDescriptors;
qlDescriptors << new QStandardItem( "Name" );
......@@ -51,7 +57,7 @@ public:
rootNode->appendRow( qlDescriptors );
QList<QStandardItem *> qlDescriptor2;
qlDescriptor2 << new QStandardItem( "Name" );
qlDescriptor2 << new QStandardItem( "weiteres" );
rootNode->appendRow( qlDescriptor2 );
QList<QStandardItem *> qlDescriptor3;
......@@ -70,6 +76,7 @@ public:
qlDescriptor3.first()->appendRow( qlDescriptor4 );
qlDescriptor3.first()->appendRow( qlDescriptor5 );
*/
};
inline ~RedstartSessionDetailsTreeView() {};
......
......@@ -19,59 +19,63 @@
#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() )
{
const QString sKey( cit->first.c_str() );
const CVAStructValue& oValue( cit->second );
cit++;
if( oValue.IsStruct() )
{
QStandardItem* pNewItem = new QStandardItem;
pItem->appendColumn( pNewItem );
ConvertVAStructToStandardItem( oValue, pNewItem );
}
QList< QStandardItem* > pItemList;
pItemList << new QStandardItem( sKey );
switch( oValue.GetDatatype() )
{
case CVAStructValue::BOOL:
{
pItem->appendColumn()[ sKey ] = bool( oValue );
pItemList << new QStandardItem( QVariant( bool( oValue ) ).toString() );
pItemList << new QStandardItem( "Bool" );
break;
}
case CVAStructValue::INT:
{
oHash[ sKey ] = int( oValue );
pItemList << new QStandardItem( QVariant( int( oValue ) ).toString() );
pItemList << new QStandardItem( "Int" );
break;
}
case CVAStructValue::DOUBLE:
{
oHash[ sKey ] = double( oValue );
pItemList << new QStandardItem( QVariant( double( oValue ) ).toString() );
pItemList << new QStandardItem( "Double" );
break;
}
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;
}
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;
}
case CVAStructValue::STRUCT:
{
BuildStandardItemFromVAStruct( oValue, pItemList.first() );
}
}
}
pItem->appendColumn( qlpItems );
*/
pRootNode->appendRow( pItemList );
}
};
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