Warning, file /libraries/kqtquickcharts/src/dimension.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  Copyright 2014  Sebastian Gottfried <sebastiangottfried@web.de>
0003  *
0004  *  This library is free software; you can redistribute it and/or
0005  *  modify it under the terms of the GNU Lesser General Public
0006  *  License as published by the Free Software Foundation; either
0007  *  version 2.1 of the License, or (at your option) version 3, or any
0008  *  later version accepted by the membership of KDE e.V. (or its
0009  *  successor approved by the membership of KDE e.V.), which shall
0010  *  act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  *  This library is distributed in the hope that it will be useful,
0013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  *  Lesser General Public License for more details.
0016  *
0017  *  You should have received a copy of the GNU Lesser General Public
0018  */
0019 
0020 #include "dimension.h"
0021 
0022 #include <QLocale>
0023 
0024 Dimension::Dimension(QObject* parent) :
0025     QObject(parent),
0026     m_color(Qt::black),
0027     m_dataColumn(0),
0028     m_minimumValue(0),
0029     m_maximumValue(256),
0030     m_precision(0),
0031     m_unitFactor(1),
0032     m_markerStyle(MarkerStyleRound),
0033     m_lineStyle(LineStyleSolid)
0034 {
0035 }
0036 
0037 QColor Dimension::color() const
0038 {
0039     return m_color;
0040 }
0041 
0042 void Dimension::setColor(const QColor &color)
0043 {
0044     if (color != m_color)
0045     {
0046         m_color = color;
0047         emit updated();
0048         emit colorChanged();
0049     }
0050 }
0051 
0052 int Dimension::dataColumn() const
0053 {
0054     return m_dataColumn;
0055 }
0056 
0057 void Dimension::setDataColumn(int dataColumn)
0058 {
0059     if (dataColumn != m_dataColumn)
0060     {
0061         m_dataColumn = dataColumn;
0062         emit updated();
0063         emit dataColumnChanged();
0064     }
0065 }
0066 
0067 qreal Dimension::minimumValue() const
0068 {
0069     return m_minimumValue;
0070 }
0071 
0072 void Dimension::setMinimumValue(qreal minimumValue)
0073 {
0074     if (minimumValue != m_minimumValue)
0075     {
0076         m_minimumValue = minimumValue;
0077         emit updated();
0078         emit minimumValueChanged();
0079     }
0080 }
0081 
0082 qreal Dimension::maximumValue() const
0083 {
0084     return m_maximumValue;
0085 }
0086 
0087 void Dimension::setMaximumValue(qreal maximumValue)
0088 {
0089     if (maximumValue != m_maximumValue)
0090     {
0091         m_maximumValue = maximumValue;
0092         emit updated();
0093         emit maximumValueChanged();
0094     }
0095 }
0096 
0097 QString Dimension::label() const
0098 {
0099     return m_label;
0100 }
0101 
0102 void Dimension::setLabel(const QString& label)
0103 {
0104     if (label != m_label)
0105     {
0106         m_label = label;
0107         emit updated();
0108         emit labelChanged();
0109     }
0110 }
0111 
0112 int Dimension::precision() const
0113 {
0114     return m_precision;
0115 }
0116 
0117 void Dimension::setPrecision(int precision)
0118 {
0119     if (precision != m_precision)
0120     {
0121         m_precision = precision;
0122         emit updated();
0123         emit precisionChanged();
0124     }
0125 }
0126 
0127 QString Dimension::unit() const
0128 {
0129     return m_unit;
0130 }
0131 
0132 void Dimension::setUnit(const QString& unit)
0133 {
0134     if (unit != m_unit)
0135     {
0136         m_unit = unit;
0137         emit updated();
0138         emit unitChanged();
0139     }
0140 }
0141 
0142 qreal Dimension::unitFactor() const
0143 {
0144     return m_unitFactor;
0145 }
0146 
0147 void Dimension::setUnitFactor(qreal unitFactor)
0148 {
0149     if (unitFactor != m_unitFactor)
0150     {
0151         m_unitFactor = unitFactor;
0152         emit updated();
0153         emit unitFactorChanged();
0154     }
0155 }
0156 
0157 QString Dimension::formatValue(qreal value)
0158 {
0159     QLocale locale;
0160     return locale.toString(value * m_unitFactor, 'f', m_precision);
0161 }
0162 
0163 Dimension::MarkerStyle Dimension::markerStyle() const
0164 {
0165     return m_markerStyle;
0166 }
0167 
0168 void Dimension::setMarkerStyle(MarkerStyle markerstyle)
0169 {
0170     if (m_markerStyle != markerstyle)
0171     {
0172         m_markerStyle = markerstyle;
0173         emit updated();
0174         emit markerStyleChanged();
0175     }
0176 }
0177 
0178 Dimension::LineStyle Dimension::lineStyle() const
0179 {
0180     return m_lineStyle;
0181 }
0182 
0183 void Dimension::setLineStyle(LineStyle lineStyle)
0184 {
0185     if (m_lineStyle != lineStyle)
0186     {
0187         m_lineStyle = lineStyle;
0188         emit updated();
0189         emit lineStyleChanged();
0190     }
0191 }