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
00030 #include <QColor>
00031
00032 #include "rviz/properties/property_tree_model.h"
00033
00034 #include "rviz/properties/status_property.h"
00035
00036 namespace rviz
00037 {
00038
00039 QColor StatusProperty::status_colors_[3] = { QColor(), QColor( 195, 180, 0 ), QColor( 178, 23, 46 ) };
00040 QString StatusProperty::status_words_[3] = { "Ok", "Warn", "Error" };
00041
00042 StatusProperty::StatusProperty( const QString& name, const QString& text, Level level, Property* parent )
00043 : Property( name, text, text, parent )
00044 , level_( level )
00045 {
00046 }
00047
00048 bool StatusProperty::setValue( const QVariant& new_value )
00049 {
00050 setDescription( new_value.toString() );
00051 return Property::setValue( new_value );
00052 }
00053
00054 QVariant StatusProperty::getViewData( int column, int role ) const
00055 {
00056 if( column == 0 && role == Qt::ForegroundRole )
00057 {
00058 return statusColor( level_ );
00059 }
00060 return Property::getViewData( column, role );
00061 }
00062
00063 Qt::ItemFlags StatusProperty::getViewFlags( int column ) const
00064 {
00065 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
00066 }
00067
00068
00069 QColor StatusProperty::statusColor( Level level )
00070 {
00071 return status_colors_[ (int) level ];
00072 }
00073
00076
00077 QString StatusProperty::statusWord( Level level )
00078 {
00079 return status_words_[ (int) level ];
00080 }
00081
00082
00083 void StatusProperty::setLevel( Level level )
00084 {
00085 if( level_ != level )
00086 {
00087 level_ = level;
00088 model_->emitDataChanged( this );
00089 }
00090 }
00091
00092 }