/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the Qwt License, Version 1.0 *****************************************************************************/ #include "qwt_legend_data.h" //! Constructor QwtLegendData::QwtLegendData() { } //! Destructor QwtLegendData::~QwtLegendData() { } /*! Set the legend attributes QwtLegendData actually is a QMap with some convenience interfaces \param map Values \sa values() */ void QwtLegendData::setValues( const QMap &map ) { d_map = map; } /*! \return Legend attributes \sa setValues() */ const QMap &QwtLegendData::values() const { return d_map; } /*! \param role Attribute role \return True, when the internal map has an entry for role */ bool QwtLegendData::hasRole( int role ) const { return d_map.contains( role ); } /*! Set an attribute value \param role Attribute role \param data Attribute value \sa value() */ void QwtLegendData::setValue( int role, const QVariant &data ) { d_map[role] = data; } /*! \param role Attribute role \return Attribute value for a specific role */ QVariant QwtLegendData::value( int role ) const { if ( !d_map.contains( role ) ) return QVariant(); return d_map[role]; } //! \return True, when the internal map is empty bool QwtLegendData::isValid() const { return !d_map.isEmpty(); } //! \return Value of the TitleRole attribute QwtText QwtLegendData::title() const { QwtText text; const QVariant titleValue = value( QwtLegendData::TitleRole ); if ( titleValue.canConvert() ) { text = qvariant_cast( titleValue ); } else if ( titleValue.canConvert() ) { text.setText( qvariant_cast( titleValue ) ); } return text; } //! \return Value of the IconRole attribute QwtGraphic QwtLegendData::icon() const { const QVariant iconValue = value( QwtLegendData::IconRole ); QwtGraphic graphic; if ( iconValue.canConvert() ) { graphic = qvariant_cast( iconValue ); } return graphic; } //! \return Value of the ModeRole attribute QwtLegendData::Mode QwtLegendData::mode() const { const QVariant modeValue = value( QwtLegendData::ModeRole ); if ( modeValue.canConvert() ) { const int mode = qvariant_cast( modeValue ); return static_cast( mode ); } return QwtLegendData::ReadOnly; }