1// Copyright (C) 2016 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 QBARMODELMAPPER_P_H
14#define QBARMODELMAPPER_P_H
15
16#include <QtCore/QObject>
17#include <QtCharts/QBarModelMapper>
18#include <QtCharts/private/qchartglobal_p.h>
19
20QT_BEGIN_NAMESPACE
21class QModelIndex;
22QT_END_NAMESPACE
23
24QT_BEGIN_NAMESPACE
25
26class QBarSet;
27
28class Q_CHARTS_PRIVATE_EXPORT QBarModelMapperPrivate : public QObject
29{
30 Q_OBJECT
31public:
32 explicit QBarModelMapperPrivate(QBarModelMapper *q);
33
34public Q_SLOTS:
35 // for the model
36 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
37 void modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last);
38 void modelRowsAdded(QModelIndex parent, int start, int end);
39 void modelRowsRemoved(QModelIndex parent, int start, int end);
40 void modelColumnsAdded(QModelIndex parent, int start, int end);
41 void modelColumnsRemoved(QModelIndex parent, int start, int end);
42 void handleModelDestroyed();
43
44 // for the series
45 void barSetsAdded(const QList<QBarSet *> &sets);
46 void barSetsRemoved(const QList<QBarSet *> &sets);
47 void valuesAdded(int index, int count);
48 void valuesRemoved(int index, int count);
49 void barLabelChanged();
50 void barValueChanged(int index);
51 void handleSeriesDestroyed();
52
53 void initializeBarFromModel();
54
55private:
56 QBarSet *barSet(QModelIndex index);
57 QModelIndex barModelIndex(int barSection, int posInBar);
58 void insertData(int start, int end);
59 void removeData(int start, int end);
60 void blockModelSignals(bool block = true);
61 void blockSeriesSignals(bool block = true);
62
63private:
64 QAbstractBarSeries *m_series;
65 QList<QBarSet *> m_barSets;
66 QAbstractItemModel *m_model;
67 int m_first;
68 int m_count;
69 Qt::Orientation m_orientation;
70 int m_firstBarSetSection;
71 int m_lastBarSetSection;
72 bool m_seriesSignalsBlock;
73 bool m_modelSignalsBlock;
74
75private:
76 QBarModelMapper *q_ptr;
77 Q_DECLARE_PUBLIC(QBarModelMapper)
78};
79
80QT_END_NAMESPACE
81
82#endif // QBARMODELMAPPER_P_H
83

source code of qtcharts/src/charts/barchart/qbarmodelmapper_p.h