1 | // Copyright (C) 2018 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // W A R N I N G |
5 | // ------------- |
6 | // |
7 | // This file is not part of the Qt Chart API. It exists purely as an |
8 | // implementation detail. This header file may change from version to |
9 | // version without notice, or even be removed. |
10 | // |
11 | // We mean it. |
12 | |
13 | #ifndef EDITABLEAXISLABEL_P_H |
14 | #define EDITABLEAXISLABEL_P_H |
15 | |
16 | #include <QtCharts/private/qchartglobal_p.h> |
17 | |
18 | #include <QtWidgets/qgraphicsitem.h> |
19 | #include <QtGui/qevent.h> |
20 | #include <QtGui/qtextdocument.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class Q_CHARTS_PRIVATE_EXPORT EditableAxisLabel : public QGraphicsTextItem |
25 | { |
26 | Q_OBJECT |
27 | public: |
28 | EditableAxisLabel(QGraphicsItem *parent = nullptr); |
29 | |
30 | void focusInEvent(QFocusEvent *event) override; |
31 | void focusOutEvent(QFocusEvent *event) override; |
32 | bool sceneEvent(QEvent *event) override; |
33 | void setEditable(bool editable); |
34 | void reloadBeforeEditContent(); |
35 | |
36 | QRectF boundingRect() const override; |
37 | |
38 | protected: |
39 | QString m_htmlBeforeEdit; |
40 | bool m_editing = false; |
41 | bool m_editable = false; |
42 | |
43 | virtual void setInitialEditValue() = 0; |
44 | virtual void finishEditing() = 0; |
45 | virtual void resetBeforeEditValue() = 0; |
46 | |
47 | bool isEditEndingKeyPress(QKeyEvent *event); |
48 | }; |
49 | |
50 | QT_END_NAMESPACE |
51 | |
52 | #endif // EDITABLEAXISLABEL_P_H |
53 | |