| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#ifndef GRID_H_ |
| 5 |
#define GRID_H_ |
| 6 |
|
| 7 |
#include "model.h" |
| 8 |
#include <QtWidgets/QGraphicsWidget> |
| 9 |
#include <QtCharts/QChartGlobal> |
| 10 |
|
| 11 |
QT_BEGIN_NAMESPACE |
| 12 |
class QGraphicsGridLayout; |
| 13 |
QT_END_NAMESPACE |
| 14 |
|
| 15 |
class Chart; |
| 16 |
|
| 17 |
QT_BEGIN_NAMESPACE |
| 18 |
class QChart; |
| 19 |
QT_END_NAMESPACE |
| 20 |
|
| 21 |
QT_USE_NAMESPACE |
| 22 |
|
| 23 |
class Grid : public QGraphicsWidget |
| 24 |
{ |
| 25 |
Q_OBJECT |
| 26 |
public: |
| 27 |
enum State { NoState = 0, ZoomState, ScrollState}; |
| 28 |
|
| 29 |
Grid(int size, QGraphicsItem *parent = 0); |
| 30 |
~Grid(); |
| 31 |
|
| 32 |
QList<QChart *> charts(); |
| 33 |
void createCharts(const QString &category = QString()); |
| 34 |
void createCharts(const QString &category, const QString &subcategory, const QString &name); |
| 35 |
void replaceChart(QChart *oldChart, Chart *newChart); |
| 36 |
void setState(State state); |
| 37 |
State state() const { return m_state; }; |
| 38 |
void setRubberPen(const QPen &pen); |
| 39 |
void setSize(int size); |
| 40 |
int size() const {return m_size;} |
| 41 |
|
| 42 |
Q_SIGNALS: |
| 43 |
void chartSelected(QChart *chart); |
| 44 |
|
| 45 |
protected: |
| 46 |
void mousePressEvent(QGraphicsSceneMouseEvent *event); |
| 47 |
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
| 48 |
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); |
| 49 |
|
| 50 |
private: |
| 51 |
void clear(); |
| 52 |
|
| 53 |
private: |
| 54 |
int m_listCount; |
| 55 |
int m_valueMax; |
| 56 |
int m_valueCount; |
| 57 |
int m_size; |
| 58 |
DataTable m_dataTable; |
| 59 |
QHash<QChart *, int> m_chartHash; |
| 60 |
QHash<int, QChart *> m_chartHashRev; |
| 61 |
State m_state; |
| 62 |
State m_currentState; |
| 63 |
QPointF m_origin; |
| 64 |
QGraphicsRectItem *m_rubberBand; |
| 65 |
QGraphicsGridLayout *m_gridLayout; |
| 66 |
}; |
| 67 |
|
| 68 |
#endif /* GRID_H_ */ |