Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "QmitkNodeDescriptor.h"
00019 #include <memory>
00020 #include <mitkNodePredicateProperty.h>
00021 #include <mitkNodePredicateAnd.h>
00022 #include <mitkNodePredicateDataType.h>
00023 #include <mitkProperties.h>
00024
00025 QmitkNodeDescriptor::QmitkNodeDescriptor( const QString& _ClassName, const QString& _PathToIcon
00026 , mitk::NodePredicateBase* _Predicate, QObject* parent )
00027 : QObject(parent)
00028 , m_ClassName(_ClassName)
00029 , m_PathToIcon(_PathToIcon)
00030 , m_Predicate(_Predicate)
00031 , m_Separator(new QAction(this))
00032 {
00033 m_Separator->setSeparator(true);
00034 }
00035
00036 QString QmitkNodeDescriptor::GetClassName() const
00037 {
00038 return m_ClassName;
00039 }
00040
00041 QIcon QmitkNodeDescriptor::GetIcon() const
00042 {
00043 return QIcon(m_PathToIcon);
00044 }
00045
00046 QList<QAction*> QmitkNodeDescriptor::GetActions() const
00047 {
00048 return m_Actions;
00049 }
00050
00051 bool QmitkNodeDescriptor::CheckNode( const mitk::DataNode* node ) const
00052 {
00053 if(m_Predicate.IsNotNull())
00054 return m_Predicate->CheckNode(node);
00055 return false;
00056 }
00057
00058 void QmitkNodeDescriptor::AddAction( QAction* action, bool isBatchAction )
00059 {
00060 if(!action)
00061 return;
00062
00063 if(isBatchAction)
00064 m_BatchActions.push_back(action);
00065 else
00066 m_Actions.push_back(action);
00067 QObject::connect( action, SIGNAL( destroyed(QObject *) )
00068 , this, SLOT( ActionDestroyed(QObject *) ) );
00069 }
00070
00071 void QmitkNodeDescriptor::RemoveAction( QAction* _Action )
00072 {
00073 int index = m_Actions.indexOf(_Action);
00074 int indexOfWidgetAction = m_BatchActions.indexOf(_Action);
00075
00076 if(index != -1)
00077 {
00078 m_Actions.removeAt(index);
00079 }
00080 else if(indexOfWidgetAction != -1)
00081 {
00082 m_BatchActions.removeAt(indexOfWidgetAction);
00083 }
00084
00085 if( _Action != 0)
00086 {
00087 QObject::disconnect( _Action, SIGNAL( destroyed(QObject *) )
00088 , this, SLOT( ActionDestroyed(QObject *) ) );
00089 }
00090 }
00091
00092 QmitkNodeDescriptor::~QmitkNodeDescriptor()
00093 {
00094
00095 }
00096
00097 QAction* QmitkNodeDescriptor::GetSeparator() const
00098 {
00099 return m_Separator;
00100 }
00101
00102 QList<QAction*> QmitkNodeDescriptor::GetBatchActions() const
00103 {
00104 return m_BatchActions;
00105 }
00106
00107 void QmitkNodeDescriptor::ActionDestroyed( QObject * obj )
00108 {
00109 this->RemoveAction( qobject_cast<QAction*>(obj) );
00110 }