Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
qwt
src
qwt_legend_data.cpp
Go to the documentation of this file.
1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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
13
QwtLegendData::QwtLegendData
()
14
{
15
}
16
18
QwtLegendData::~QwtLegendData
()
19
{
20
}
21
31
void
QwtLegendData::setValues
(
const
QMap<int, QVariant> &map )
32
{
33
d_map
= map;
34
}
35
40
const
QMap<int, QVariant> &
QwtLegendData::values
()
const
41
{
42
return
d_map
;
43
}
44
49
bool
QwtLegendData::hasRole
(
int
role )
const
50
{
51
return
d_map
.contains( role );
52
}
53
62
void
QwtLegendData::setValue
(
int
role,
const
QVariant &data )
63
{
64
d_map
[role] = data;
65
}
66
71
QVariant
QwtLegendData::value
(
int
role )
const
72
{
73
if
( !
d_map
.contains( role ) )
74
return
QVariant();
75
76
return
d_map
[role];
77
}
78
80
bool
QwtLegendData::isValid
()
const
81
{
82
return
!
d_map
.isEmpty();
83
}
84
86
QwtText
QwtLegendData::title
()
const
87
{
88
QwtText
text;
89
90
const
QVariant titleValue =
value
(
QwtLegendData::TitleRole
);
91
if
( titleValue.canConvert<
QwtText
>() )
92
{
93
text = qvariant_cast<
QwtText
>( titleValue );
94
}
95
else
if
( titleValue.canConvert<QString>() )
96
{
97
text.
setText
( qvariant_cast<QString>( titleValue ) );
98
}
99
100
return
text;
101
}
102
104
QwtGraphic
QwtLegendData::icon
()
const
105
{
106
const
QVariant iconValue =
value
(
QwtLegendData::IconRole
);
107
108
QwtGraphic
graphic;
109
if
( iconValue.canConvert<
QwtGraphic
>() )
110
{
111
graphic = qvariant_cast<
QwtGraphic
>( iconValue );
112
}
113
114
return
graphic;
115
}
116
118
QwtLegendData::Mode
QwtLegendData::mode
()
const
119
{
120
const
QVariant modeValue =
value
(
QwtLegendData::ModeRole
);
121
if
( modeValue.canConvert<
int
>() )
122
{
123
const
int
mode
= qvariant_cast<
int
>( modeValue );
124
return
static_cast<
QwtLegendData::Mode
>
(
mode
);
125
}
126
127
return
QwtLegendData::ReadOnly
;
128
}
129
QwtLegendData::ModeRole
Definition:
qwt_legend_data.h:55
QwtText::setText
void setText(const QString &, QwtText::TextFormat textFormat=AutoText)
Definition:
qwt_text.cpp:244
QwtLegendData::setValues
void setValues(const QMap< int, QVariant > &)
Definition:
qwt_legend_data.cpp:31
QwtLegendData::IconRole
Definition:
qwt_legend_data.h:61
QwtLegendData::ReadOnly
The legend item is not interactive, like a label.
Definition:
qwt_legend_data.h:42
QwtLegendData::d_map
QMap< int, QVariant > d_map
Definition:
qwt_legend_data.h:84
QwtLegendData::hasRole
bool hasRole(int role) const
Definition:
qwt_legend_data.cpp:49
QwtLegendData::~QwtLegendData
~QwtLegendData()
Destructor.
Definition:
qwt_legend_data.cpp:18
QwtLegendData::QwtLegendData
QwtLegendData()
Constructor.
Definition:
qwt_legend_data.cpp:13
QwtText
A class representing a text.
Definition:
qwt_text.h:51
QwtLegendData::value
QVariant value(int role) const
Definition:
qwt_legend_data.cpp:71
QwtLegendData::icon
QwtGraphic icon() const
Definition:
qwt_legend_data.cpp:104
QwtGraphic
A paint device for scalable graphics.
Definition:
qwt_graphic.h:74
QwtLegendData::TitleRole
Definition:
qwt_legend_data.h:58
QwtLegendData::mode
Mode mode() const
Definition:
qwt_legend_data.cpp:118
QwtLegendData::title
QwtText title() const
Definition:
qwt_legend_data.cpp:86
QwtLegendData::values
const QMap< int, QVariant > & values() const
Definition:
qwt_legend_data.cpp:40
qwt_legend_data.h
QwtLegendData::setValue
void setValue(int role, const QVariant &)
Definition:
qwt_legend_data.cpp:62
QwtLegendData::isValid
bool isValid() const
Definition:
qwt_legend_data.cpp:80
QwtLegendData::Mode
Mode
Mode defining how a legend entry interacts.
Definition:
qwt_legend_data.h:39
plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17