qwt_legend_data.cpp
/******************************************************************************
* 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"
#include "qwt_text.h"
#include "qwt_graphic.h"
QwtLegendData::QwtLegendData()
{
}
QwtLegendData::~QwtLegendData()
{
}
void QwtLegendData::setValues( const QMap< int, QVariant >& map )
{
m_map = map;
}
const QMap< int, QVariant >& QwtLegendData::values() const
{
return m_map;
}
bool QwtLegendData::hasRole( int role ) const
{
return m_map.contains( role );
}
void QwtLegendData::setValue( int role, const QVariant& data )
{
m_map[role] = data;
}
QVariant QwtLegendData::value( int role ) const
{
if ( !m_map.contains( role ) )
return QVariant();
return m_map[role];
}
bool QwtLegendData::isValid() const
{
return !m_map.isEmpty();
}
QwtText QwtLegendData::title() const
{
QwtText text;
const QVariant titleValue = value( QwtLegendData::TitleRole );
if ( titleValue.canConvert< QwtText >() )
{
text = qvariant_cast< QwtText >( titleValue );
}
else if ( titleValue.canConvert< QString >() )
{
text.setText( qvariant_cast< QString >( titleValue ) );
}
return text;
}
QwtGraphic QwtLegendData::icon() const
{
const QVariant iconValue = value( QwtLegendData::IconRole );
QwtGraphic graphic;
if ( iconValue.canConvert< QwtGraphic >() )
{
graphic = qvariant_cast< QwtGraphic >( iconValue );
}
return graphic;
}
QwtLegendData::Mode QwtLegendData::mode() const
{
const QVariant modeValue = value( QwtLegendData::ModeRole );
if ( modeValue.canConvert< int >() )
{
const int mode = qvariant_cast< int >( modeValue );
return static_cast< QwtLegendData::Mode >( mode );
}
return QwtLegendData::ReadOnly;
}
QMap< int, QVariant >
QwtGraphic
A paint device for scalable graphics.
Definition: qwt_graphic.h:76
QwtLegendData::mode
Mode mode() const
Definition: qwt_legend_data.cpp:120
QwtLegendData::setValue
void setValue(int role, const QVariant &)
Definition: qwt_legend_data.cpp:64
QwtLegendData::QwtLegendData
QwtLegendData()
Constructor.
Definition: qwt_legend_data.cpp:15
QwtLegendData::~QwtLegendData
~QwtLegendData()
Destructor.
Definition: qwt_legend_data.cpp:20
QwtLegendData::setValues
void setValues(const QMap< int, QVariant > &)
Definition: qwt_legend_data.cpp:33
QwtLegendData::value
QVariant value(int role) const
Definition: qwt_legend_data.cpp:73
QwtLegendData::isValid
bool isValid() const
Definition: qwt_legend_data.cpp:82
QwtLegendData::Mode
Mode
Mode defining how a legend entry interacts.
Definition: qwt_legend_data.h:41
QwtLegendData::ReadOnly
@ ReadOnly
The legend item is not interactive, like a label.
Definition: qwt_legend_data.h:43
QwtLegendData::hasRole
bool hasRole(int role) const
Definition: qwt_legend_data.cpp:51
QwtLegendData::values
const QMap< int, QVariant > & values() const
Definition: qwt_legend_data.cpp:42
QwtLegendData::icon
QwtGraphic icon() const
Definition: qwt_legend_data.cpp:106
QwtLegendData::title
QwtText title() const
Definition: qwt_legend_data.cpp:88
QwtText
A class representing a text.
Definition: qwt_text.h:52
QwtText::setText
void setText(const QString &, QwtText::TextFormat textFormat=AutoText)
Definition: qwt_text.cpp:277