summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklós Márton <martonmiklosqdev@gmail.com>2018-09-13 22:43:26 +0200
committerMiklós Márton <martonmiklosqdev@gmail.com>2018-10-30 10:11:05 +0000
commit796419e32863c1d322d5f9af1fedd032bdd738d7 (patch)
tree9a7638f1a107a9b55de0f2ad086e218de7dd12a3
parent7f1e35a01880346e6e1a735f3e474ca4e9e257f5 (diff)
Add label editing feature to the QValueAxis
Add a new property (labelsEditable) to the QAbstractAxis. If this property set to true the user will be able to manipulate the axis labels by double clicking on it and entering a new value. After finishing the edit the axis range will adjusted according to the entered value. At the moment only the QValueAxis is supported, but I am planning to add support for QLogValueAxis, and QDateTimeAxis after the basic implementation details got reviewed. Change-Id: Id87ebfbfb37ed00f09cf7b651395cf3caead1dbb Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/charts/axis/axis.pri2
-rw-r--r--src/charts/axis/cartesianchartaxis.cpp41
-rw-r--r--src/charts/axis/cartesianchartaxis_p.h3
-rw-r--r--src/charts/axis/chartaxiselement.cpp41
-rw-r--r--src/charts/axis/chartaxiselement_p.h6
-rw-r--r--src/charts/axis/qabstractaxis.cpp37
-rw-r--r--src/charts/axis/qabstractaxis.h6
-rw-r--r--src/charts/axis/qabstractaxis_p.h1
-rw-r--r--src/charts/axis/valueaxis/chartvalueaxisx.cpp2
-rw-r--r--src/charts/axis/valueaxis/chartvalueaxisy.cpp2
-rw-r--r--src/charts/axis/valueaxis/qvalueaxis.cpp1
-rw-r--r--src/charts/axis/valueaxis/valueaxislabel.cpp162
-rw-r--r--src/charts/axis/valueaxis/valueaxislabel_p.h80
13 files changed, 383 insertions, 1 deletions
diff --git a/src/charts/axis/axis.pri b/src/charts/axis/axis.pri
index 340f5b35..4909e77c 100644
--- a/src/charts/axis/axis.pri
+++ b/src/charts/axis/axis.pri
@@ -15,6 +15,7 @@ SOURCES += \
$$PWD/valueaxis/chartvalueaxisx.cpp \
$$PWD/valueaxis/chartvalueaxisy.cpp \
$$PWD/valueaxis/qvalueaxis.cpp \
+ $$PWD/valueaxis/valueaxislabel.cpp \
$$PWD/barcategoryaxis/chartbarcategoryaxisx.cpp \
$$PWD/barcategoryaxis/chartbarcategoryaxisy.cpp \
$$PWD/barcategoryaxis/qbarcategoryaxis.cpp \
@@ -35,6 +36,7 @@ PRIVATE_HEADERS += \
$$PWD/valueaxis/chartvalueaxisx_p.h \
$$PWD/valueaxis/chartvalueaxisy_p.h \
$$PWD/valueaxis/qvalueaxis_p.h \
+ $$PWD/valueaxis/valueaxislabel_p.h \
$$PWD/barcategoryaxis/chartbarcategoryaxisx_p.h \
$$PWD/barcategoryaxis/chartbarcategoryaxisy_p.h \
$$PWD/barcategoryaxis/qbarcategoryaxis_p.h \
diff --git a/src/charts/axis/cartesianchartaxis.cpp b/src/charts/axis/cartesianchartaxis.cpp
index 571af7a9..34e618c2 100644
--- a/src/charts/axis/cartesianchartaxis.cpp
+++ b/src/charts/axis/cartesianchartaxis.cpp
@@ -81,7 +81,17 @@ void CartesianChartAxis::createItems(int count)
for (int i = 0; i < count; ++i) {
QGraphicsLineItem *arrow = new QGraphicsLineItem(this);
QGraphicsLineItem *grid = new QGraphicsLineItem(this);
- QGraphicsTextItem *label = new QGraphicsTextItem(this);
+ QGraphicsTextItem *label = axis()->type() == QAbstractAxis::AxisTypeValue
+ ? new ValueAxisLabel(this)
+ : new QGraphicsTextItem(this);
+ if (axis()->type() == QAbstractAxis::AxisTypeValue) {
+ ValueAxisLabel *valueLabel = static_cast<ValueAxisLabel *>(label);
+ connect(valueLabel, &ValueAxisLabel::valueChanged,
+ this, &ChartAxisElement::labelEdited);
+ // only QValueAxis labels editable for now
+ if (labelsEditable())
+ valueLabel->setEditable(true);
+ }
label->document()->setDocumentMargin(ChartPresenter::textMargin());
arrow->setPen(axis()->linePen());
grid->setPen(axis()->gridLinePen());
@@ -327,6 +337,35 @@ void CartesianChartAxis::handleShadesPenChanged(const QPen &pen)
static_cast<QGraphicsRectItem *>(item)->setPen(pen);
}
+void CartesianChartAxis::updateLabelsValues(QValueAxis *axis)
+{
+ const QVector<qreal> &layout = ChartAxisElement::layout();
+ if (layout.isEmpty())
+ return;
+
+ if (axis->tickType() == QValueAxis::TicksFixed) {
+ for (int i = 0; i < layout.size(); ++i) {
+ qreal value = axis->isReverse()
+ ? min() + ((layout.size() - 1 - i) * (max() - min()) / (layout.size() - 1))
+ : min() + (i * (max() - min()) / (layout.size() - 1));
+ static_cast<ValueAxisLabel *>(labelItems().at(i))->setValue(value);
+ }
+ } else {
+ qreal value = axis->tickAnchor();
+ if (value > min())
+ value = value - int((value - min()) / axis->tickInterval()) * axis->tickInterval();
+ else
+ value = value + qCeil((min() - value) / axis->tickInterval()) * axis->tickInterval();
+
+ int i = axis->isReverse() ? labelItems().count()-1 : 0;
+ while (value <= max() || qFuzzyCompare(value, max())) {
+ static_cast<ValueAxisLabel *>(labelItems().at(i))->setValue(value);
+ value += axis->tickInterval();
+ i += axis->isReverse() ? -1 : 1;
+ }
+ }
+}
+
QT_CHARTS_END_NAMESPACE
#include "moc_cartesianchartaxis_p.cpp"
diff --git a/src/charts/axis/cartesianchartaxis_p.h b/src/charts/axis/cartesianchartaxis_p.h
index 60cabd19..dc274522 100644
--- a/src/charts/axis/cartesianchartaxis_p.h
+++ b/src/charts/axis/cartesianchartaxis_p.h
@@ -77,6 +77,9 @@ public Q_SLOTS:
virtual void handleGridLineColorChanged(const QColor &color);
virtual void handleMinorGridLineColorChanged(const QColor &color);
+protected:
+ void updateLabelsValues(QValueAxis *axis);
+
private:
void createItems(int count);
void deleteItems(int count);
diff --git a/src/charts/axis/chartaxiselement.cpp b/src/charts/axis/chartaxiselement.cpp
index fc2b3e27..bf33d330 100644
--- a/src/charts/axis/chartaxiselement.cpp
+++ b/src/charts/axis/chartaxiselement.cpp
@@ -157,6 +157,30 @@ void ChartAxisElement::handleLabelsPositionChanged()
presenter()->layout()->invalidate();
}
+void ChartAxisElement::labelEdited(qreal oldValue, qreal newValue)
+{
+ qreal range = max() - min();
+ qreal center = ((max() - min()) / 2) + min();
+ qreal newRange = 0.0;
+ auto label = static_cast<ValueAxisLabel *>(this->sender());
+ if ((oldValue >= center && newValue >= min())
+ || (oldValue < center && newValue >= max() && oldValue != min())) {
+ newRange = range * ((newValue - min()) / (oldValue - min()));
+ if (newRange > 0) {
+ m_axis->setRange(min(), min() + newRange);
+ return;
+ }
+ } else if ((oldValue >= center && newValue <= min() && max() != oldValue)
+ || (oldValue < center && newValue < max())) {
+ newRange = range * ((max() - newValue) / (max() - oldValue));
+ if (newRange > 0) {
+ m_axis->setRange(max() - newRange, max());
+ return;
+ }
+ }
+ label->reloadBeforeEditContent();
+}
+
void ChartAxisElement::handleLabelsVisibleChanged(bool visible)
{
QGraphicsLayoutItem::updateGeometry();
@@ -502,6 +526,23 @@ QStringList ChartAxisElement::createDateTimeLabels(qreal min, qreal max,int tick
return labels;
}
+
+bool ChartAxisElement::labelsEditable() const
+{
+ return m_labelsEditable;
+}
+
+void ChartAxisElement::setLabelsEditable(bool labelsEditable)
+{
+ if (axis()->type() == QAbstractAxis::AxisTypeValue) {
+ labelGroup()->setHandlesChildEvents(!labelsEditable);
+ const QList<QGraphicsItem *> childItems = labelGroup()->childItems();
+ for (auto item : childItems)
+ static_cast<ValueAxisLabel *>(item)->setEditable(labelsEditable);
+ m_labelsEditable = labelsEditable;
+ }
+}
+
void ChartAxisElement::axisSelected()
{
emit clicked();
diff --git a/src/charts/axis/chartaxiselement_p.h b/src/charts/axis/chartaxiselement_p.h
index 7aced068..4bc1475e 100644
--- a/src/charts/axis/chartaxiselement_p.h
+++ b/src/charts/axis/chartaxiselement_p.h
@@ -43,6 +43,7 @@
#include <QtCharts/private/qchartglobal_p.h>
#include <private/chartelement_p.h>
#include <private/axisanimation_p.h>
+#include <private/valueaxislabel_p.h>
#include <QtWidgets/QGraphicsItem>
#include <QtWidgets/QGraphicsLayoutItem>
#include <QtCharts/QValueAxis>
@@ -111,6 +112,9 @@ public:
{
}
+ bool labelsEditable() const;
+ void setLabelsEditable(bool labelsEditable);
+
protected:
virtual QVector<qreal> calculateLayout() const = 0;
virtual void updateLayout(QVector<qreal> &layout) = 0;
@@ -155,6 +159,7 @@ public Q_SLOTS:
void handleMinorArrowVisibleChanged(bool visible);
void handleMinorGridVisibleChanged(bool visible);
void handleLabelsPositionChanged();
+ void labelEdited(qreal oldValue, qreal newValue);
Q_SIGNALS:
void clicked();
@@ -179,6 +184,7 @@ private:
QScopedPointer<QGraphicsItemGroup> m_labels;
QScopedPointer<QGraphicsTextItem> m_title;
bool m_intervalAxis;
+ bool m_labelsEditable = false;
};
QT_CHARTS_END_NAMESPACE
diff --git a/src/charts/axis/qabstractaxis.cpp b/src/charts/axis/qabstractaxis.cpp
index 73fa5920..ed246536 100644
--- a/src/charts/axis/qabstractaxis.cpp
+++ b/src/charts/axis/qabstractaxis.cpp
@@ -102,6 +102,17 @@ QT_CHARTS_BEGIN_NAMESPACE
*/
/*!
+ \property QAbstractAxis::labelsEditable
+ \since 5.13
+ \brief This property holds whether the labels of the axis are editable or not.
+ When the labels set to editable the user will be able to change the range of the
+ axis conveniently by editing any of the labels. This feature is only implemented
+ for the QValueAxis.
+
+ By default, the value is \c false.
+*/
+
+/*!
\property QAbstractAxis::labelsBrush
\brief The brush used to draw the labels.
@@ -368,6 +379,12 @@ QT_CHARTS_BEGIN_NAMESPACE
*/
/*!
+ \fn void QAbstractAxis::labelsEditableChanged(bool editable)
+ \since 5.13
+ This signal is emitted when the labels editability changes.
+*/
+
+/*!
\fn void QAbstractAxis::gridVisibleChanged(bool visible)
This signal is emitted when the visibility of the grid lines of the axis changes to \a visible.
*/
@@ -948,6 +965,25 @@ bool QAbstractAxis::isReverse() const
return d_ptr->m_reverse;
}
+void QAbstractAxis::setLabelsEditable(bool editable)
+{
+ if (d_ptr->m_labelsEditable != editable) {
+ // In the case if the axis already added to a chart
+ // set the labels editability on the axisItem().
+ // Otherwise the labels editability will be set in the
+ // QValueAxisPrivate::initializeGraphics.
+ if (d_ptr->axisItem() != nullptr)
+ d_ptr->axisItem()->setLabelsEditable(editable);
+ d_ptr->m_labelsEditable = editable;
+ emit labelsEditableChanged(editable);
+ }
+}
+
+bool QAbstractAxis::labelsEditable() const
+{
+ return d_ptr->m_labelsEditable;
+}
+
void QAbstractAxis::setReverse(bool reverse)
{
if (d_ptr->m_reverse != reverse && type() != QAbstractAxis::AxisTypeBarCategory) {
@@ -972,6 +1008,7 @@ QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q)
m_minorGridLineVisible(true),
m_minorGridLinePen(QChartPrivate::defaultPen()),
m_labelsVisible(true),
+ m_labelsEditable(false),
m_labelsBrush(QChartPrivate::defaultBrush()),
m_labelsFont(QChartPrivate::defaultFont()),
m_labelsAngle(0),
diff --git a/src/charts/axis/qabstractaxis.h b/src/charts/axis/qabstractaxis.h
index 4f902679..a1b91a43 100644
--- a/src/charts/axis/qabstractaxis.h
+++ b/src/charts/axis/qabstractaxis.h
@@ -54,6 +54,7 @@ class QT_CHARTS_EXPORT QAbstractAxis : public QObject
Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged)
Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
+ Q_PROPERTY(bool labelsEditable READ labelsEditable WRITE setLabelsEditable NOTIFY labelsEditableChanged)
//grid
Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged)
@@ -173,6 +174,10 @@ public:
void setReverse(bool reverse = true);
bool isReverse() const;
+ //label editable handling
+ void setLabelsEditable(bool editable = true);
+ bool labelsEditable() const;
+
Q_SIGNALS:
void visibleChanged(bool visible);
void linePenChanged(const QPen &pen);
@@ -199,6 +204,7 @@ Q_SIGNALS:
void shadesPenChanged(const QPen &pen);
void shadesBrushChanged(const QBrush &brush);
void reverseChanged(bool reverse);
+ void labelsEditableChanged(bool editable);
protected:
QScopedPointer<QAbstractAxisPrivate> d_ptr;
diff --git a/src/charts/axis/qabstractaxis_p.h b/src/charts/axis/qabstractaxis_p.h
index 3a635d98..ee3af6a0 100644
--- a/src/charts/axis/qabstractaxis_p.h
+++ b/src/charts/axis/qabstractaxis_p.h
@@ -117,6 +117,7 @@ private:
QPen m_minorGridLinePen;
bool m_labelsVisible;
+ bool m_labelsEditable;
QBrush m_labelsBrush;
QFont m_labelsFont;
int m_labelsAngle;
diff --git a/src/charts/axis/valueaxis/chartvalueaxisx.cpp b/src/charts/axis/valueaxis/chartvalueaxisx.cpp
index 6eeda781..3eac86e0 100644
--- a/src/charts/axis/valueaxis/chartvalueaxisx.cpp
+++ b/src/charts/axis/valueaxis/chartvalueaxisx.cpp
@@ -32,6 +32,7 @@
#include <private/chartpresenter_p.h>
#include <QtCharts/QValueAxis>
#include <private/abstractchartlayout_p.h>
+#include <private/valueaxislabel_p.h>
#include <QtWidgets/QGraphicsLayout>
#include <QtCore/QtMath>
#include <QtCore/QDebug>
@@ -107,6 +108,7 @@ void ChartValueAxisX::updateGeometry()
setLabels(createValueLabels(min(), max(), layout.size(), m_axis->tickInterval(),
m_axis->tickAnchor(), m_axis->tickType(), m_axis->labelFormat()));
HorizontalAxis::updateGeometry();
+ updateLabelsValues(m_axis);
}
void ChartValueAxisX::handleTickCountChanged(int tick)
diff --git a/src/charts/axis/valueaxis/chartvalueaxisy.cpp b/src/charts/axis/valueaxis/chartvalueaxisy.cpp
index 961b292e..c4868fc2 100644
--- a/src/charts/axis/valueaxis/chartvalueaxisy.cpp
+++ b/src/charts/axis/valueaxis/chartvalueaxisy.cpp
@@ -32,6 +32,7 @@
#include <private/chartpresenter_p.h>
#include <QtCharts/QValueAxis>
#include <private/abstractchartlayout_p.h>
+#include <private/valueaxislabel_p.h>
#include <QtWidgets/QGraphicsLayout>
#include <QtCore/QtMath>
#include <QtCore/QDebug>
@@ -108,6 +109,7 @@ void ChartValueAxisY::updateGeometry()
setLabels(createValueLabels(min(), max(), layout.size(), m_axis->tickInterval(),
m_axis->tickAnchor(), m_axis->tickType(), m_axis->labelFormat()));
VerticalAxis::updateGeometry();
+ updateLabelsValues(m_axis);
}
void ChartValueAxisY::handleTickCountChanged(int tick)
diff --git a/src/charts/axis/valueaxis/qvalueaxis.cpp b/src/charts/axis/valueaxis/qvalueaxis.cpp
index 1d179e43..905168d7 100644
--- a/src/charts/axis/valueaxis/qvalueaxis.cpp
+++ b/src/charts/axis/valueaxis/qvalueaxis.cpp
@@ -533,6 +533,7 @@ void QValueAxisPrivate::initializeGraphics(QGraphicsItem *parent)
axis = new ChartValueAxisY(q,parent);
if (orientation() == Qt::Horizontal)
axis = new ChartValueAxisX(q,parent);
+ axis->setLabelsEditable(q->labelsEditable());
}
if (m_chart->chartType() == QChart::ChartTypePolar) {
diff --git a/src/charts/axis/valueaxis/valueaxislabel.cpp b/src/charts/axis/valueaxis/valueaxislabel.cpp
new file mode 100644
index 00000000..cd81a857
--- /dev/null
+++ b/src/charts/axis/valueaxis/valueaxislabel.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Charts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "valueaxislabel_p.h"
+
+#include <QtCore/qlocale.h>
+#include <QtGui/qevent.h>
+#include <QtGui/qtextcursor.h>
+#include <QtGui/qtextdocument.h>
+
+QT_CHARTS_BEGIN_NAMESPACE
+
+ValueAxisLabel::ValueAxisLabel(QGraphicsItem *parent) :
+ QGraphicsTextItem(parent)
+{
+
+}
+
+void ValueAxisLabel::focusInEvent(QFocusEvent *event)
+{
+ m_htmlBeforeEdit = toHtml();
+ setTextWidth(-1);
+ m_valueBeforeEdit = m_value;
+ setHtml(QString::number(m_value));
+ m_editing = true;
+ QGraphicsTextItem::focusInEvent(event);
+}
+
+void ValueAxisLabel::focusOutEvent(QFocusEvent *event)
+{
+ // perform the modifications before emitting valueChanged
+ // because slots attached to valueChanged can trigger
+ // a range change which might invalidate the current label
+ QGraphicsTextItem::focusOutEvent(event);
+ setTextInteractionFlags(Qt::NoTextInteraction);
+ m_editing = false;
+
+ bool ok = false;
+ QLocale locale;
+ qreal oldValue = m_value;
+ qreal newValue = locale.toDouble(document()->toPlainText(), &ok);
+ if (ok && newValue != m_value) {
+ m_value = newValue;
+ emit valueChanged(oldValue, newValue);
+ } else {
+ document()->setHtml(m_htmlBeforeEdit);
+ }
+}
+
+qreal ValueAxisLabel::value() const
+{
+ return m_value;
+}
+
+void ValueAxisLabel::setValue(const qreal &value)
+{
+ setTextInteractionFlags(Qt::NoTextInteraction);
+ clearFocus();
+ m_value = value;
+}
+
+void ValueAxisLabel::reloadBeforeEditContent()
+{
+ m_value = m_valueBeforeEdit;
+ setHtml(m_htmlBeforeEdit);
+}
+
+QRectF ValueAxisLabel::boundingRect() const
+{
+ QRectF ret = QGraphicsTextItem::boundingRect();
+
+ // add 2px margin to allow the cursor to
+ // show up properly when editing
+ if (m_editing)
+ ret.setWidth(ret.width() + 2);
+ return ret;
+}
+
+void ValueAxisLabel::setEditable(bool editable)
+{
+ m_editable = editable;
+}
+
+void ValueAxisLabel::keyPressEvent(QKeyEvent *event)
+{
+ if (event->text().length() >= 1) {
+ // finish editing with enter
+ if (event->key() == Qt::Key_Enter ||
+ event->key() == Qt::Key_Return) {
+ clearFocus();
+ // prevent further event processing with a return
+ // because the focusOutEvent could have triggered
+ // a range change which might have invalidated the current label
+ return;
+ } else if (event->key() == Qt::Key_Escape) {
+ document()->setHtml(m_htmlBeforeEdit);
+ clearFocus();
+ // prevent further event processing with a return
+ // because the focusOutEvent could have triggered
+ // a range change which might have invalidated the current label
+ return;
+ }
+
+ QLocale locale;
+ if (!event->text().at(0).isDigit()
+ && event->text().at(0) != locale.decimalPoint()
+ && event->text().at(0) != locale.negativeSign()
+ && event->text().at(0) != locale.exponential()
+ && event->key() != Qt::Key_Backspace
+ && event->key() != Qt::Key_Delete) {
+ event->ignore();
+ return;
+ }
+ }
+ QGraphicsTextItem::keyPressEvent(event);
+}
+
+bool ValueAxisLabel::sceneEvent(QEvent *event)
+{
+ if (m_editable && event->type() == QEvent::GraphicsSceneMouseDoubleClick) {
+ setTextInteractionFlags(Qt::TextEditorInteraction);
+
+ bool ret = QGraphicsTextItem::sceneEvent(event);
+ // QGraphicsTextItem::sceneevent needs to be processed before
+ // the focus and text selection
+ setFocus(Qt::MouseFocusReason);
+ QTextCursor cursor = textCursor();
+ cursor.select(QTextCursor::Document);
+ setTextCursor(cursor);
+ return ret;
+ }
+ return QGraphicsTextItem::sceneEvent(event);
+}
+
+QT_CHARTS_END_NAMESPACE
+
+#include "moc_valueaxislabel_p.cpp"
diff --git a/src/charts/axis/valueaxis/valueaxislabel_p.h b/src/charts/axis/valueaxis/valueaxislabel_p.h
new file mode 100644
index 00000000..14f3eb48
--- /dev/null
+++ b/src/charts/axis/valueaxis/valueaxislabel_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Charts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt Chart API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef VALUEAXISLABEL_H
+#define VALUEAXISLABEL_H
+
+#include <QtWidgets/qgraphicsitem.h>
+#include <QtCharts/private/qchartglobal_p.h>
+
+QT_CHARTS_BEGIN_NAMESPACE
+
+class QT_CHARTS_PRIVATE_EXPORT ValueAxisLabel : public QGraphicsTextItem
+{
+ Q_OBJECT
+public:
+ ValueAxisLabel(QGraphicsItem *parent = nullptr);
+
+ void focusInEvent(QFocusEvent *event);
+ void focusOutEvent(QFocusEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+
+ bool sceneEvent(QEvent *event);
+
+ qreal value() const;
+ void setValue(const qreal &value);
+ void reloadBeforeEditContent();
+
+ QRectF boundingRect() const;
+
+ void setEditable(bool editable);
+
+private:
+ qreal m_value = 0.0;
+ qreal m_valueBeforeEdit = 0.0;
+ QString m_htmlBeforeEdit;
+ bool m_editing = false;
+ bool m_editable = false;
+
+signals:
+ void valueChanged(qreal oldValue, qreal newValue);
+};
+
+QT_CHARTS_END_NAMESPACE
+
+#endif // VALUEAXISLABEL_H