00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef PROPERTY_TREE_WIDGET_H
00030 #define PROPERTY_TREE_WIDGET_H
00031
00032 #include <QTreeView>
00033
00034 #include "rviz/properties/property_tree_model.h"
00035
00036 namespace YAML
00037 {
00038 class Node;
00039 class Emitter;
00040 }
00041
00042 namespace rviz
00043 {
00044
00045 class Property;
00046 class SplitterHandle;
00047
00048 class PropertyTreeWidget: public QTreeView
00049 {
00050 Q_OBJECT
00051 public:
00052 PropertyTreeWidget( QWidget* parent = 0 );
00053
00055 void setModel( PropertyTreeModel* model );
00056 PropertyTreeModel* getModel() const { return model_; }
00057
00059 template<class Type>
00060 QList<Type*> getSelectedObjects()
00061 {
00062 QModelIndexList indexes = selectedIndexes();
00063 int num_selected = indexes.size();
00064
00065 QList<Type*> objects_out;
00066
00067 for( int i = 0; i < num_selected; i++ )
00068 {
00069 if( indexes[ i ].column() == 0 )
00070 {
00071 Property* prop = model_->getProp( indexes[ i ] );
00072 if( prop != model_->getRoot() )
00073 {
00074 Type* obj = qobject_cast<Type*>( prop );
00075 if( obj )
00076 {
00077 objects_out.push_back( obj );
00078 }
00079 }
00080 }
00081 }
00082 return objects_out;
00083 }
00084
00086 void save( YAML::Emitter& emitter );
00087
00089 void load( const YAML::Node& yaml_node );
00090
00091 protected:
00094 virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
00095
00098 virtual void selectionChanged( const QItemSelection& selected, const QItemSelection& deselected );
00099
00100 protected Q_SLOTS:
00101 virtual void propertyHiddenChanged( const Property* property );
00102
00103 Q_SIGNALS:
00104 void currentPropertyChanged( const Property* new_current_property );
00105 void selectionHasChanged();
00106
00107 private:
00109 void saveExpandedEntries( YAML::Emitter& emitter, const QModelIndex& parent_index, const QString& prefix );
00110
00112 void expandEntries( const QSet<QString>& expanded_full_names,
00113 const QModelIndex& parent_index,
00114 const QString& prefix );
00115
00116 PropertyTreeModel* model_;
00117 SplitterHandle* splitter_handle_;
00118 };
00119
00120 }
00121
00122 #endif // PROPERTY_TREE_WIDGET_H