From 632a74f2bb1998093332ed01ec52cac7997f1b49 Mon Sep 17 00:00:00 2001 From: zcy Date: Wed, 4 Aug 2021 17:15:42 +0800 Subject: [PATCH] no message --- widgets/chart_callout.cpp | 137 ++++++++++++++++++++++++++++++++++++ widgets/chart_callout.h | 72 +++++++++++++++++++ widgets/drilldownchart.cpp | 69 ++++++++++++++++++ widgets/drilldownchart.h | 62 ++++++++++++++++ widgets/drilldownseries.cpp | 60 ++++++++++++++++ widgets/drilldownseries.h | 60 ++++++++++++++++ widgets/loading_widget.cpp | 48 +++++++++++++ widgets/loading_widget.h | 26 +++++++ widgets/qchartwrap.cpp | 107 ++++++++++++++++++++++++++++ widgets/qchartwrap.h | 81 +++++++++++++++++++++ 10 files changed, 722 insertions(+) create mode 100644 widgets/chart_callout.cpp create mode 100644 widgets/chart_callout.h create mode 100644 widgets/drilldownchart.cpp create mode 100644 widgets/drilldownchart.h create mode 100644 widgets/drilldownseries.cpp create mode 100644 widgets/drilldownseries.h create mode 100644 widgets/loading_widget.cpp create mode 100644 widgets/loading_widget.h create mode 100644 widgets/qchartwrap.cpp create mode 100644 widgets/qchartwrap.h diff --git a/widgets/chart_callout.cpp b/widgets/chart_callout.cpp new file mode 100644 index 0000000..f0cfcf9 --- /dev/null +++ b/widgets/chart_callout.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "chart_callout.h" +#include +#include +#include +#include +#include + +ChartCallout::ChartCallout(QChart *chart): + QGraphicsItem(chart), + m_chart(chart) +{ + +} + +QRectF ChartCallout::boundingRect() const +{ + QPointF anchor = mapFromParent(m_chart->mapToPosition(m_anchor)); + QRectF rect; + rect.setLeft(qMin(m_rect.left(), anchor.x())); + rect.setRight(qMax(m_rect.right(), anchor.x())); + rect.setTop(qMin(m_rect.top(), anchor.y())); + rect.setBottom(qMax(m_rect.bottom(), anchor.y())); + return rect; +} + +void ChartCallout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option) + Q_UNUSED(widget) + QPainterPath path; + path.addRoundedRect(m_rect, 5, 5); + + QPointF anchor = mapFromParent(m_chart->mapToPosition(m_anchor)); + if (!m_rect.contains(anchor)) { + QPointF point1, point2; + + // establish the position of the anchor point in relation to m_rect + bool above = anchor.y() <= m_rect.top(); + bool aboveCenter = anchor.y() > m_rect.top() && anchor.y() <= m_rect.center().y(); + bool belowCenter = anchor.y() > m_rect.center().y() && anchor.y() <= m_rect.bottom(); + bool below = anchor.y() > m_rect.bottom(); + + bool onLeft = anchor.x() <= m_rect.left(); + bool leftOfCenter = anchor.x() > m_rect.left() && anchor.x() <= m_rect.center().x(); + bool rightOfCenter = anchor.x() > m_rect.center().x() && anchor.x() <= m_rect.right(); + bool onRight = anchor.x() > m_rect.right(); + + // get the nearest m_rect corner. + qreal x = (onRight + rightOfCenter) * m_rect.width(); + qreal y = (below + belowCenter) * m_rect.height(); + bool cornerCase = (above && onLeft) || (above && onRight) || (below && onLeft) || (below && onRight); + bool vertical = qAbs(anchor.x() - x) > qAbs(anchor.y() - y); + + qreal x1 = x + leftOfCenter * 10 - rightOfCenter * 20 + cornerCase * !vertical * (onLeft * 10 - onRight * 20); + qreal y1 = y + aboveCenter * 10 - belowCenter * 20 + cornerCase * vertical * (above * 10 - below * 20);; + point1.setX(x1); + point1.setY(y1); + + qreal x2 = x + leftOfCenter * 20 - rightOfCenter * 10 + cornerCase * !vertical * (onLeft * 20 - onRight * 10);; + qreal y2 = y + aboveCenter * 20 - belowCenter * 10 + cornerCase * vertical * (above * 20 - below * 10);; + point2.setX(x2); + point2.setY(y2); + + path.moveTo(point1); + path.lineTo(anchor); + path.lineTo(point2); + path = path.simplified(); + } + painter->setBrush(QColor(255, 255, 255)); + painter->drawPath(path); + painter->drawText(m_textRect, m_text); +} + +void ChartCallout::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + event->setAccepted(true); +} + +void ChartCallout::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->buttons() & Qt::LeftButton){ + setPos(mapToParent(event->pos() - event->buttonDownPos(Qt::LeftButton))); + event->setAccepted(true); + } else { + event->setAccepted(false); + } +} + +void ChartCallout::setText(const QString &text) +{ + m_text = text; + QFontMetrics metrics(m_font); + m_textRect = metrics.boundingRect(QRect(0, 0, 150, 150), Qt::AlignLeft, m_text); + m_textRect.translate(5, 5); + prepareGeometryChange(); + m_rect = m_textRect.adjusted(-5, -5, 5, 5); +} + +void ChartCallout::setAnchor(QPointF point) +{ + m_anchor = point; +} + +void ChartCallout::updateGeometry() +{ + prepareGeometryChange(); + setPos(m_chart->mapToPosition(m_anchor) + QPoint(10, -50)); +} diff --git a/widgets/chart_callout.h b/widgets/chart_callout.h new file mode 100644 index 0000000..0debbee --- /dev/null +++ b/widgets/chart_callout.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef CALLOUT_H +#define CALLOUT_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QGraphicsSceneMouseEvent; +QT_END_NAMESPACE + +QT_CHARTS_BEGIN_NAMESPACE +class QChart; +QT_CHARTS_END_NAMESPACE + +QT_CHARTS_USE_NAMESPACE + +class ChartCallout : public QGraphicsItem +{ +public: + ChartCallout(QChart *parent); + + void setText(const QString &text); + void setAnchor(QPointF point); + void updateGeometry(); + + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + +private: + QString m_text; + QRectF m_textRect; + QRectF m_rect; + QPointF m_anchor; + QFont m_font; + QChart *m_chart; +}; + +#endif // CALLOUT_H diff --git a/widgets/drilldownchart.cpp b/widgets/drilldownchart.cpp new file mode 100644 index 0000000..2acdb7f --- /dev/null +++ b/widgets/drilldownchart.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "drilldownchart.h" +#include +#include + +QT_CHARTS_USE_NAMESPACE + +DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) + : QChart(QChart::ChartTypeCartesian, parent, wFlags), + m_currentSeries(0), + m_axisX(new QBarCategoryAxis()), + m_axisY(new QValueAxis()) +{ + addAxis(m_axisY, Qt::AlignLeft); + addAxis(m_axisX, Qt::AlignBottom); +} + +void DrilldownChart::changeSeries(DrilldownBarSeries *series) +{ + if (m_currentSeries) + removeSeries(m_currentSeries); + + m_currentSeries = series; + + // Reset axis + m_axisX->setCategories(m_currentSeries->categories()); + addSeries(series); + series->attachAxis(m_axisX); + series->attachAxis(m_axisY); + m_axisY->setRange(0,m_currentSeries->maxValue()); + setTitle(series->name()); +} + +void DrilldownChart::handleClicked(int index, QBarSet *barset) +{ + Q_UNUSED(barset) + DrilldownBarSeries *series = static_cast(sender()); + changeSeries(series->drilldownSeries(index)); +} + +#include "moc_drilldownchart.cpp" diff --git a/widgets/drilldownchart.h b/widgets/drilldownchart.h new file mode 100644 index 0000000..61fdbc6 --- /dev/null +++ b/widgets/drilldownchart.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef DRILLDOWNCHART_H +#define DRILLDOWNCHART_H + +#include +#include "drilldownseries.h" + +namespace QtCharts { +class QBarCategoryAxis; +class QValueAxis; +} + +QT_CHARTS_USE_NAMESPACE + +//! [1] +class DrilldownChart : public QChart +{ + Q_OBJECT +public: + explicit DrilldownChart(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = {}); + + void changeSeries(DrilldownBarSeries *series); + +public Q_SLOTS: + void handleClicked(int index, QBarSet *barset); + +private: + DrilldownBarSeries *m_currentSeries; + QBarCategoryAxis *m_axisX; + QValueAxis *m_axisY; +}; +//! [1] + +#endif // DRILLDOWNCHART_H diff --git a/widgets/drilldownseries.cpp b/widgets/drilldownseries.cpp new file mode 100644 index 0000000..93b1409 --- /dev/null +++ b/widgets/drilldownseries.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "drilldownseries.h" + +QT_CHARTS_USE_NAMESPACE + +DrilldownBarSeries::DrilldownBarSeries(QStringList categories, int maxValue, QObject *parent) + : QStackedBarSeries(parent), + m_maxValue(maxValue) +{ + m_categories = categories; +} + +void DrilldownBarSeries::mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries) +{ + m_DrilldownSeries[index] = drilldownSeries; +} + +DrilldownBarSeries *DrilldownBarSeries::drilldownSeries(int index) +{ + return m_DrilldownSeries[index]; +} + +QStringList DrilldownBarSeries::categories() +{ + return m_categories; +} + +int DrilldownBarSeries::maxValue() +{ + return m_maxValue; +} + diff --git a/widgets/drilldownseries.h b/widgets/drilldownseries.h new file mode 100644 index 0000000..7cd28f0 --- /dev/null +++ b/widgets/drilldownseries.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef DRILLDOWNSERIES_H +#define DRILLDOWNSERIES_H + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +//! [1] +class DrilldownBarSeries : public QStackedBarSeries +{ + Q_OBJECT +public: + DrilldownBarSeries(QStringList categories, int maxValue, QObject *parent = 0); + + void mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries); + + DrilldownBarSeries *drilldownSeries(int index); + + QStringList categories(); + + int maxValue(); + +private: + QMap m_DrilldownSeries; + QStringList m_categories; + int m_maxValue; +}; +//! [1] + +#endif // DRILLDOWNSERIES_H diff --git a/widgets/loading_widget.cpp b/widgets/loading_widget.cpp new file mode 100644 index 0000000..ba80f46 --- /dev/null +++ b/widgets/loading_widget.cpp @@ -0,0 +1,48 @@ +#include "loading_widget.h" +#include +#include + + +LoadingAnimationWidget::LoadingAnimationWidget(QWidget *parent) : + QWidget(parent), + m_rotate(false), + m_timer(nullptr), + m_pixmap(nullptr) +{ + m_timer = new QTimer(this); + qDebug()<<"LoadingAnimationWidget"; + connect(m_timer,SIGNAL(timeout()),this,SLOT(timerout())); +} + +void LoadingAnimationWidget::SetPixmap(QPixmap *p) +{ + connect(m_timer,SIGNAL(timeout()),this,SLOT(timerout())); + + m_timer->setInterval(100); + m_timer->start(40); + m_pixmap = p; +} + +void LoadingAnimationWidget::timerout() +{ + m_rotate =true; + update(); +} + +void LoadingAnimationWidget::paintEvent(QPaintEvent *) +{ + static int rotate = 0; + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing,true); + painter.translate(width()/2,height()/2); + + if(m_rotate) + { + rotate = (rotate+5)%360; + m_rotate =false; + } + + painter.rotate(rotate); + if(nullptr != m_pixmap) + painter.drawPixmap(-m_pixmap->width()/2,-m_pixmap->height()/2,*m_pixmap); +} diff --git a/widgets/loading_widget.h b/widgets/loading_widget.h new file mode 100644 index 0000000..fc1fa85 --- /dev/null +++ b/widgets/loading_widget.h @@ -0,0 +1,26 @@ +#ifndef LOADING_WIDGET_H +#define LOADING_WIDGET_H +#include +#include +#include + +class LoadingAnimationWidget:public QWidget +{ + Q_OBJECT +public: + LoadingAnimationWidget(QWidget *parent); + LoadingAnimationWidget(QWidget *parent,QPixmap*); + void SetPixmap(QPixmap*); + bool m_rotate; + QTimer *m_timer; + QPixmap *m_pixmap; +public slots: + void timerout(); + +protected: + void paintEvent(QPaintEvent *); +private: + LoadingAnimationWidget(); +}; + +#endif // LOADING_WIDGET_H diff --git a/widgets/qchartwrap.cpp b/widgets/qchartwrap.cpp new file mode 100644 index 0000000..9fb5646 --- /dev/null +++ b/widgets/qchartwrap.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "qchartwrap.h" +#include +#include +#include +#include +#include +#include +#include "chart_callout.h" +#include + +QChartWrap::QChartWrap(QWidget *parent) + : QChartView(parent), + m_coordX(0), + m_coordY(0), + m_tooltip(0) +{ + setDragMode(QGraphicsView::NoDrag); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + // chart + this->chart()->setAcceptHoverEvents(true); + + setRenderHint(QPainter::Antialiasing); + scene()->addItem(this->chart()); + m_coordX = new QGraphicsSimpleTextItem(this->chart()); + m_coordX->setPos(0, this->chart()->size().height()); + m_coordX->setText("X: "); + m_coordY = new QGraphicsSimpleTextItem(this->chart()); + m_coordY->setPos(100, this->chart()->size().height()); + m_coordY->setText("Y: "); + + this->setMouseTracking(true); + this->chart()->setMargins(QMargins(0,0,0,0)); +} + +void QChartWrap::resizeEvent(QResizeEvent *event) +{ + if (scene()) { + scene()->setSceneRect(QRect(QPoint(0, 0), event->size())); + this->chart()->resize(event->size()); + m_coordX->setPos(0, this->chart()->size().height() - 20); + m_coordY->setPos(100, this->chart()->size().height() - 20); + const auto callouts = m_callouts; + for (ChartCallout *callout : callouts) + callout->updateGeometry(); + } + QChartView::resizeEvent(event); +} + +void QChartWrap::mouseMoveEvent(QMouseEvent *event) +{ + m_coordX->setText(QString("X: %1").arg(this->chart()->mapToValue(event->pos()).x())); + m_coordY->setText(QString("Y: %1").arg(this->chart()->mapToValue(event->pos()).y())); + QChartView::mouseMoveEvent(event); +} + +void QChartWrap::keepCallout() +{ + m_callouts.append(m_tooltip); + m_tooltip = new ChartCallout(this->chart()); +} + +void QChartWrap::tooltip(QPointF point, bool state) +{ + if (m_tooltip == 0) + m_tooltip = new ChartCallout(this->chart()); + + if (state) { + m_tooltip->setText(QString("X: %1 \nY: %2 ").arg(point.x()).arg(point.y())); + m_tooltip->setAnchor(point); + m_tooltip->setZValue(11); + m_tooltip->updateGeometry(); + m_tooltip->show(); + } else { + m_tooltip->hide(); + } +} diff --git a/widgets/qchartwrap.h b/widgets/qchartwrap.h new file mode 100644 index 0000000..2e1bda3 --- /dev/null +++ b/widgets/qchartwrap.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef VIEW_H +#define VIEW_H +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QGraphicsScene; +class QMouseEvent; +class QResizeEvent; +QT_END_NAMESPACE + +QT_CHARTS_BEGIN_NAMESPACE +class QChart; +QT_CHARTS_END_NAMESPACE + +class ChartCallout; + +QT_CHARTS_USE_NAMESPACE + + +class QChartWrap: public QChartView +{ + Q_OBJECT + +public: + QChartWrap(QWidget *parent = 0); + +protected: + void resizeEvent(QResizeEvent *event); + void mouseMoveEvent(QMouseEvent *event); + +public slots: + void keepCallout(); + void tooltip(QPointF point, bool state); + +private: + QGraphicsSimpleTextItem *m_coordX; + QGraphicsSimpleTextItem *m_coordY; + ChartCallout *m_tooltip; + QList m_callouts; +}; + +#endif