source: ntrip/trunk/BNC/qwt/qwt_legend_data.cpp@ 10532

Last change on this file since 10532 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 2.7 KB
RevLine 
[8127]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
12//! Constructor
13QwtLegendData::QwtLegendData()
14{
15}
16
17//! Destructor
18QwtLegendData::~QwtLegendData()
19{
20}
21
22/*!
23 Set the legend attributes
24
25 QwtLegendData actually is a QMap<int, QVariant> with some
26 convenience interfaces
27
28 \param map Values
29 \sa values()
30 */
31void QwtLegendData::setValues( const QMap<int, QVariant> &map )
32{
33 d_map = map;
34}
35
36/*!
37 \return Legend attributes
38 \sa setValues()
39 */
40const QMap<int, QVariant> &QwtLegendData::values() const
41{
42 return d_map;
43}
44
45/*!
46 \param role Attribute role
47 \return True, when the internal map has an entry for role
48 */
49bool QwtLegendData::hasRole( int role ) const
50{
51 return d_map.contains( role );
52}
53
54/*!
55 Set an attribute value
56
57 \param role Attribute role
58 \param data Attribute value
59
60 \sa value()
61 */
62void QwtLegendData::setValue( int role, const QVariant &data )
63{
64 d_map[role] = data;
65}
66
67/*!
68 \param role Attribute role
69 \return Attribute value for a specific role
70 */
71QVariant QwtLegendData::value( int role ) const
72{
73 if ( !d_map.contains( role ) )
74 return QVariant();
75
76 return d_map[role];
77}
78
79//! \return True, when the internal map is empty
80bool QwtLegendData::isValid() const
81{
82 return !d_map.isEmpty();
83}
84
85//! \return Value of the TitleRole attribute
86QwtText 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
103//! \return Value of the IconRole attribute
104QwtGraphic 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
117//! \return Value of the ModeRole attribute
118QwtLegendData::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 }
[9383]126
[8127]127 return QwtLegendData::ReadOnly;
128}
129
Note: See TracBrowser for help on using the repository browser.