Qwt User's Guide
6.3.0
Loading...
Searching...
No Matches
qwt_legend_data.cpp
1
/******************************************************************************
2
* Qwt Widget Library
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the Qwt License, Version 1.0
8
*****************************************************************************/
9
10
#include "qwt_legend_data.h"
11
#include "qwt_text.h"
12
#include "qwt_graphic.h"
13
15
QwtLegendData::QwtLegendData
()
16
{
17
}
18
20
QwtLegendData::~QwtLegendData
()
21
{
22
}
23
33
void
QwtLegendData::setValues
(
const
QMap< int, QVariant >
& map )
34
{
35
m_map = map;
36
}
37
42
const
QMap< int, QVariant >
&
QwtLegendData::values
()
const
43
{
44
return
m_map;
45
}
46
51
bool
QwtLegendData::hasRole
(
int
role )
const
52
{
53
return
m_map.contains( role );
54
}
55
64
void
QwtLegendData::setValue
(
int
role,
const
QVariant& data )
65
{
66
m_map[role] = data;
67
}
68
73
QVariant
QwtLegendData::value
(
int
role )
const
74
{
75
if
( !m_map.contains( role ) )
76
return
QVariant();
77
78
return
m_map[role];
79
}
80
82
bool
QwtLegendData::isValid
()
const
83
{
84
return
!m_map.isEmpty();
85
}
86
88
QwtText
QwtLegendData::title
()
const
89
{
90
QwtText
text;
91
92
const
QVariant titleValue =
value
( QwtLegendData::TitleRole );
93
if
( titleValue.canConvert<
QwtText
>() )
94
{
95
text = qvariant_cast< QwtText >( titleValue );
96
}
97
else
if
( titleValue.canConvert< QString >() )
98
{
99
text.
setText
( qvariant_cast< QString >( titleValue ) );
100
}
101
102
return
text;
103
}
104
106
QwtGraphic
QwtLegendData::icon
()
const
107
{
108
const
QVariant iconValue =
value
( QwtLegendData::IconRole );
109
110
QwtGraphic
graphic;
111
if
( iconValue.canConvert<
QwtGraphic
>() )
112
{
113
graphic = qvariant_cast< QwtGraphic >( iconValue );
114
}
115
116
return
graphic;
117
}
118
120
QwtLegendData::Mode
QwtLegendData::mode
()
const
121
{
122
const
QVariant modeValue =
value
( QwtLegendData::ModeRole );
123
if
( modeValue.canConvert<
int
>() )
124
{
125
const
int
mode
= qvariant_cast< int >( modeValue );
126
return
static_cast<
QwtLegendData::Mode
>
(
mode
);
127
}
128
129
return
QwtLegendData::ReadOnly
;
130
}
131
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
src
qwt_legend_data.cpp
Generated by
1.10.0