Commit 87f70c63 authored by schurade's avatar schurade
Browse files

[CHANGE] enum for tree items, clean up

parent 2feda690
......@@ -247,7 +247,7 @@ void WQtDatasetBrowser::addRoi( boost::shared_ptr< WRMROIRepresentation > roi )
{
switch ( m_treeWidget->selectedItems().at( 0 )->type() )
{
case 5 :
case ROI :
{
WQtRoiTreeItem* roiItem =( ( WQtRoiTreeItem* ) m_treeWidget->selectedItems().at( 0 ) );
m_tiRois->setExpanded( true );
......@@ -256,7 +256,7 @@ void WQtDatasetBrowser::addRoi( boost::shared_ptr< WRMROIRepresentation > roi )
item->setDisabled( false );
break;
}
case 6 :
case SUBROI :
{
WQtRoiTreeItem* roiItem =( ( WQtRoiTreeItem* ) m_treeWidget->selectedItems().at( 0 )->parent() );
m_tiRois->setExpanded( true );
......@@ -309,21 +309,25 @@ void WQtDatasetBrowser::selectTreeItem()
{
switch ( m_treeWidget->selectedItems().at( 0 )->type() )
{
case 0:
case SUBJECT:
break;
case 1:
case 3:
module = ( ( WQtModuleTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
case DATASET:
module = ( static_cast< WQtDatasetTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
props = module->getProperties()->getPropertyVector();
createCompatibleButtons( module );
break;
case 2:
case MODULEHEADER:
break;
case 4:
case MODULE:
module = ( static_cast< WQtModuleTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
props = module->getProperties()->getPropertyVector();
createCompatibleButtons( module );
break;
case ROIHEADER:
break;
case 5:
case 6:
props = ( ( WQtRoiTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getRoi()->getProperties()->getPropertyVector();
case ROI:
case SUBROI:
props = ( static_cast< WQtRoiTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getRoi()->getProperties()->getPropertyVector();
break;
default:
break;
......@@ -401,9 +405,9 @@ void WQtDatasetBrowser::createCompatibleButtons( boost::shared_ptr< WModule >mod
void WQtDatasetBrowser::changeTreeItem()
{
if ( m_treeWidget->selectedItems().size() == 1 && m_treeWidget->selectedItems().at( 0 )->type() == 1 )
if ( m_treeWidget->selectedItems().size() == 1 && m_treeWidget->selectedItems().at( 0 )->type() == DATASET )
{
boost::shared_ptr< WModule >module =( ( WQtDatasetTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
boost::shared_ptr< WModule >module =( static_cast< WQtDatasetTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
if ( m_treeWidget->selectedItems().at( 0 )->checkState( 0 ) )
{
module->getProperties()->setValue<bool>( "active", true );
......@@ -414,9 +418,9 @@ void WQtDatasetBrowser::changeTreeItem()
}
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
else if ( m_treeWidget->selectedItems().size() == 1 && m_treeWidget->selectedItems().at( 0 )->type() == 3 )
else if ( m_treeWidget->selectedItems().size() == 1 && m_treeWidget->selectedItems().at( 0 )->type() == MODULE )
{
boost::shared_ptr< WModule >module =( ( WQtModuleTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
boost::shared_ptr< WModule >module =( static_cast< WQtModuleTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
if ( m_treeWidget->selectedItems().at( 0 )->checkState( 0 ) )
{
module->getProperties()->setValue<bool>( "active", true );
......@@ -472,20 +476,23 @@ boost::shared_ptr< WProperties > WQtDatasetBrowser::getPropOfSelected()
{
switch ( m_treeWidget->selectedItems().at( 0 )->type() )
{
case 0:
case SUBJECT:
break;
case DATASET:
module = ( static_cast< WQtModuleTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
props = module->getProperties();
break;
case 1:
case 3:
module = ( ( WQtModuleTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
case MODULE:
module = ( static_cast< WQtModuleTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
props = module->getProperties();
break;
case 2:
case MODULEHEADER:
break;
case 4:
case ROIHEADER:
break;
case 5:
case 6:
props = ( ( WQtRoiTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getRoi()->getProperties();
case ROI:
case SUBROI:
props = ( static_cast< WQtRoiTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getRoi()->getProperties();
break;
default:
break;
......@@ -507,8 +514,8 @@ std::vector< boost::shared_ptr< WDataSet > > WQtDatasetBrowser::getDataSetList(
for ( int i = 0 ; i < count ; ++i )
{
boost::shared_ptr< WMData > dm = boost::shared_dynamic_cast< WMData >( ( ( WQtDatasetTreeItem* )m_treeWidget->invisibleRootItem()->child(
subjectId + c )->child( i ) )->getModule() );
boost::shared_ptr< WMData > dm = boost::shared_dynamic_cast< WMData >( ( static_cast< WQtDatasetTreeItem* >(
m_treeWidget->invisibleRootItem()->child( subjectId + c )->child( i ) ) )->getModule() );
if ( dm->isReady()() && ( !onlyTextures || dm->getDataSet()->isTexture() ) )
{
......@@ -538,7 +545,7 @@ int WQtDatasetBrowser::getFirstSubject()
int c = 0;
for ( int i = 0; i < m_treeWidget->topLevelItemCount() ; ++i )
{
if ( m_treeWidget->topLevelItem( i )->type() == 0 )
if ( m_treeWidget->topLevelItem( i )->type() == SUBJECT )
{
break;
}
......@@ -554,14 +561,14 @@ boost::shared_ptr< WRMROIRepresentation > WQtDatasetBrowser::getSelectedRoi()
{
return roi;
}
if ( m_treeWidget->selectedItems().at( 0 )->type() == 5 )
if ( m_treeWidget->selectedItems().at( 0 )->type() == ROI )
{
roi =( ( WQtRoiTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getRoi();
roi =( static_cast< WQtRoiTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getRoi();
std::cout << "return this" << std::endl;
}
if ( m_treeWidget->selectedItems().at( 0 )->type() == 6 )
if ( m_treeWidget->selectedItems().at( 0 )->type() == SUBROI )
{
roi =( ( WQtRoiTreeItem* ) m_treeWidget->selectedItems().at( 0 )->parent() )->getRoi();
roi =( static_cast< WQtRoiTreeItem* >( m_treeWidget->selectedItems().at( 0 )->parent() ) )->getRoi();
std::cout << "return parent" << std::endl;
}
return roi;
......
......@@ -24,10 +24,12 @@
#include <string>
#include "WTreeItemTypes.h"
#include "WQtDatasetTreeItem.h"
WQtDatasetTreeItem::WQtDatasetTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module )
: WQtTreeItem( parent, 1, module )
: WQtTreeItem( parent, DATASET, module )
{
// replace the name by the filename
m_name = module->getProperties()->getValue< std::string >( "filename" );
......
......@@ -24,10 +24,12 @@
#include <string>
#include "WTreeItemTypes.h"
#include "WQtModuleHeaderTreeItem.h"
WQtModuleHeaderTreeItem::WQtModuleHeaderTreeItem( QTreeWidget * parent ) :
QTreeWidgetItem( parent, 2 )
QTreeWidgetItem( parent, MODULEHEADER )
{
}
......
......@@ -22,10 +22,12 @@
//
//---------------------------------------------------------------------------
#include "WTreeItemTypes.h"
#include "WQtModuleTreeItem.h"
WQtModuleTreeItem::WQtModuleTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module ) :
WQtTreeItem( parent, 3, module )
WQtTreeItem( parent, MODULE, module )
{
}
......
......@@ -24,12 +24,13 @@
#include <string>
#include "WTreeItemTypes.h"
#include "WQtRoiTreeItem.h"
#include "WQtRoiHeaderTreeItem.h"
WQtRoiHeaderTreeItem::WQtRoiHeaderTreeItem( QTreeWidget * parent ) :
QTreeWidgetItem( parent, 4 )
QTreeWidgetItem( parent, ROIHEADER )
{
}
......
......@@ -24,9 +24,10 @@
#include <string>
#include "WTreeItemTypes.h"
#include "WQtRoiTreeItem.h"
WQtRoiTreeItem::WQtRoiTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WRMROIRepresentation > roi, int type ) :
WQtRoiTreeItem::WQtRoiTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WRMROIRepresentation > roi, WTreeItemType type ) :
QTreeWidgetItem( parent, type ),
m_roi( roi )
{
......@@ -43,7 +44,7 @@ boost::shared_ptr< WRMROIRepresentation > WQtRoiTreeItem::getRoi()
WQtRoiTreeItem* WQtRoiTreeItem::addRoiItem( boost::shared_ptr< WRMROIRepresentation > roi )
{
WQtRoiTreeItem* rti = new WQtRoiTreeItem( this, roi, 6 );
WQtRoiTreeItem* rti = new WQtRoiTreeItem( this, roi, SUBROI );
std::string name = "ROI";
rti->setText( 0, QString( name.c_str() ) );
......
......@@ -46,7 +46,7 @@ public:
* \param roi
* \param type
*/
WQtRoiTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WRMROIRepresentation > roi, int type = 5 );
WQtRoiTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WRMROIRepresentation > roi, WTreeItemType type = ROI );
/**
* destructor
......
......@@ -24,10 +24,12 @@
#include <string>
#include "WTreeItemTypes.h"
#include "WQtSubjectTreeItem.h"
WQtSubjectTreeItem::WQtSubjectTreeItem( QTreeWidget * parent )
: QTreeWidgetItem( parent, 0 ) // type 0
: QTreeWidgetItem( parent, SUBJECT ) // type 0
{
}
......
......@@ -28,9 +28,10 @@
#include "../../../common/WProgressCombiner.h"
#include "../../../common/WProgress.h"
#include "WTreeItemTypes.h"
#include "WQtTreeItem.h"
WQtTreeItem::WQtTreeItem( QTreeWidgetItem * parent, int type, boost::shared_ptr< WModule > module ) :
WQtTreeItem::WQtTreeItem( QTreeWidgetItem * parent, WTreeItemType type, boost::shared_ptr< WModule > module ) :
QTreeWidgetItem( parent, type )
{
m_module = module;
......
......@@ -30,6 +30,8 @@
#include <QtGui/QTreeWidgetItem>
#include <QtGui/QProgressBar>
#include <QtCore/QTimer>
#include "WTreeItemTypes.h"
#include "../../../kernel/WModule.h"
/**
......@@ -48,7 +50,7 @@ public:
* \param module The represented module
* \param type the type used for the treeitem. Used to identify the items.
*/
WQtTreeItem( QTreeWidgetItem * parent, int type, boost::shared_ptr< WModule > module );
WQtTreeItem( QTreeWidgetItem * parent, WTreeItemType type, boost::shared_ptr< WModule > module );
/**
* Destructor.
......
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