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_MODEL_H
00030 #define PROPERTY_MODEL_H
00031
00032 #include <QAbstractItemModel>
00033
00034 namespace rviz
00035 {
00036
00037 class Property;
00038
00039 class PropertyTreeModel: public QAbstractItemModel
00040 {
00041 Q_OBJECT
00042 public:
00048 PropertyTreeModel( Property* root_property, QObject* parent = 0 );
00049
00052 virtual ~PropertyTreeModel();
00053
00054
00055 virtual QVariant data( const QModelIndex &index, int role ) const;
00056 virtual QVariant headerData( int section, Qt::Orientation orientation,
00057 int role = Qt::DisplayRole ) const;
00058
00059 virtual QModelIndex index( int row, int column,
00060 const QModelIndex &parent = QModelIndex() ) const;
00061 virtual QModelIndex parent( const QModelIndex &index ) const;
00062
00065 QModelIndex parentIndex( const Property* child ) const;
00066
00068 virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
00069
00072 virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const { return 2; }
00073
00074
00075 virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
00076 virtual bool setData( const QModelIndex &index, const QVariant &value,
00077 int role = Qt::EditRole );
00078
00079 virtual Qt::DropActions supportedDropActions() const { return Qt::MoveAction; }
00080
00087 virtual QMimeData* mimeData( const QModelIndexList& indexes ) const;
00088
00096 virtual bool dropMimeData( const QMimeData* data,
00097 Qt::DropAction action,
00098 int destination_row, int destination_column,
00099 const QModelIndex& destination_parent );
00100
00103 virtual QStringList mimeTypes () const;
00104
00105 Property* getRoot() const { return root_property_; }
00106
00107 QModelIndex indexOf( Property* property ) const;
00108
00109 void emitDataChanged( Property* property );
00110
00111 void beginInsert( Property* parent_property, int row_within_parent, int count = 1 );
00112 void endInsert();
00113
00114 void beginRemove( Property* parent_property, int row_within_parent, int count = 1 );
00115 void endRemove();
00116
00119 Property* getProp( const QModelIndex& index ) const;
00120
00122 void emitPropertyHiddenChanged( const Property* property ) { Q_EMIT propertyHiddenChanged( property ); }
00123
00125 void expandProperty( Property* property );
00126
00128 void collapseProperty( Property* property );
00129
00132 void printPersistentIndices();
00133
00134 Q_SIGNALS:
00136 void propertyHiddenChanged( const Property* property );
00137
00139 void configChanged();
00140
00142 void expand( const QModelIndex& index );
00143
00145 void collapse( const QModelIndex& index );
00146
00147 private:
00148 Property* root_property_;
00149 };
00150
00151 }
00152
00153 #endif // PROPERTY_MODEL_H