property.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 #ifndef PROPERTY_H
00030 #define PROPERTY_H
00031 
00032 #include <string>
00033 
00034 #include <QObject>
00035 #include <QIcon>
00036 #include <QVariant>
00037 
00038 #include "rviz/config.h"
00039 
00040 class QModelIndex;
00041 class QPainter;
00042 class QStyleOptionViewItem;
00043 
00044 namespace rviz
00045 {
00046 
00047 class PropertyTreeModel;
00048 
00100 class Property: public QObject
00101 {
00102 Q_OBJECT
00103 public:
00130   Property( const QString& name = QString(),
00131             const QVariant default_value = QVariant(),
00132             const QString& description = QString(),
00133             Property* parent = 0,
00134             const char *changed_slot = 0,
00135             QObject* receiver = 0 );
00136 
00140   virtual ~Property();
00141 
00148   virtual void removeChildren( int start_index = 0, int count = -1 );
00149 
00161   virtual bool setValue( const QVariant& new_value );
00162 
00165   virtual QVariant getValue() const;
00166 
00171   virtual void setName( const QString& name );
00172 
00174   virtual QString getName() const;
00175 
00177   std::string getNameStd() const { return getName().toStdString(); }
00178 
00181   virtual void setDescription( const QString& description );
00182 
00184   virtual QString getDescription() const;
00185 
00187   virtual void setIcon( const QIcon& icon ) { icon_=icon; }
00188 
00189   virtual QIcon getIcon() const { return icon_; }
00190 
00209   virtual Property* subProp( const QString& sub_name );
00210 
00215   virtual int numChildren() const { return children_.size(); }
00216 
00224   Property* childAt( int index ) const;
00225 
00231   virtual Property* childAtUnchecked( int index ) const;
00232 
00234   bool contains( Property* possible_child ) const;
00235 
00237   Property* getParent() const;
00238 
00245   void setParent( Property* new_parent );
00246 
00259   virtual QVariant getViewData( int column, int role ) const;
00260 
00265   virtual Qt::ItemFlags getViewFlags( int column ) const;
00266 
00276   virtual bool paint( QPainter* painter,
00277                       const QStyleOptionViewItem& option ) const { return false; }
00278 
00279 
00296   virtual QWidget* createEditor( QWidget* parent,
00297                                  const QStyleOptionViewItem& option );
00298 
00302   bool isAncestorOf( Property* possible_child ) const;
00303 
00312   Property* takeChild( Property* child );
00313 
00318   virtual Property* takeChildAt( int index );
00319 
00325   virtual void addChild( Property* child, int index = -1 );
00326 
00328   void setModel( PropertyTreeModel* model );
00329 
00331   PropertyTreeModel* getModel() const { return model_; }
00332 
00339   int rowNumberInParent() const;
00340 
00342   virtual void moveChild( int from_index, int to_index );
00343 
00346   virtual void load( const Config& config );
00347 
00350   virtual void save( Config config ) const;
00351 
00353   bool shouldBeSaved() const { return !is_read_only_ && save_; }
00354 
00357   void setShouldBeSaved( bool save ) { save_ = save; }
00358 
00361   virtual bool getDisableChildren();
00362 
00367   void hide() { setHidden( true ); }
00368 
00373   void show() { setHidden( false ); }
00374 
00380   virtual void setHidden( bool hidden );
00381 
00384   virtual bool getHidden() const { return hidden_; }
00385 
00393   virtual void setReadOnly( bool read_only ) { is_read_only_ = read_only; }
00394 
00397   virtual bool getReadOnly() { return is_read_only_; }
00398 
00403   virtual void collapse();
00404 
00414   virtual void expand();
00415 
00416 Q_SIGNALS:
00418   void aboutToChange();
00420   void changed();
00421 
00423   void childListChanged( Property* this_property );
00424 
00425 protected:
00430   void loadValue( const Config& config );
00431 
00436   QVariant value_;
00437 
00450   PropertyTreeModel* model_;
00451 
00457   bool child_indexes_valid_;
00458 
00459   QIcon icon_;
00460 
00461 private:
00464   void reindexChildren();
00465 
00466   Property* parent_;
00467   QList<Property*> children_;
00468   QString description_;
00469   bool hidden_;
00470 
00473   static Property* failprop_;
00474 
00475   int row_number_within_parent_;
00476   bool is_read_only_;
00477   bool save_;
00478 };
00479 
00480 } // end namespace rviz
00481 
00482 #endif // PROPERTY_H


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Mon Oct 6 2014 07:26:35