KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
KDChartDiagramObserver.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
14
15#include <KDABLibFakes>
16
17#include <QDebug>
18
19using namespace KDChart;
20
22 : QObject(parent)
23 , m_diagram(diagram)
24{
25 if (m_diagram) {
26 connect(m_diagram, &AbstractDiagram::destroyed, this, &DiagramObserver::slotDestroyed);
27 connect(m_diagram, &AbstractDiagram::aboutToBeDestroyed, this, &DiagramObserver::slotAboutToBeDestroyed);
28 connect(m_diagram, &AbstractDiagram::modelsChanged, this, &DiagramObserver::slotModelsChanged);
29 }
30 init();
31}
32
36
38{
39 return m_diagram;
40}
41
43{
44 return m_diagram;
45}
46
47void DiagramObserver::init()
48{
49 if (!m_diagram)
50 return;
51
52 if (m_model)
53 disconnect(m_model);
54
55 if (m_attributesmodel)
56 disconnect(m_attributesmodel);
57
59 this, QOverload<>::of(&DiagramObserver::slotDataChanged));
62 connect(m_diagram, &AbstractDiagram::dataHidden, this, &DiagramObserver::slotDataHidden);
63
64 if (m_diagram->model()) {
66 this, QOverload<QModelIndex, QModelIndex>::of(&DiagramObserver::slotDataChanged));
68 this, QOverload<>::of(&DiagramObserver::slotDataChanged));
70 this, QOverload<>::of(&DiagramObserver::slotDataChanged));
72 this, QOverload<>::of(&DiagramObserver::slotDataChanged));
74 this, QOverload<>::of(&DiagramObserver::slotDataChanged));
76 this, QOverload<>::of(&DiagramObserver::slotDataChanged));
78 this, &DiagramObserver::slotHeaderDataChanged);
79 }
80
81 if (m_diagram->attributesModel())
83 this, QOverload<QModelIndex, QModelIndex>::of(&DiagramObserver::slotAttributesChanged));
84 m_model = m_diagram->model();
85 m_attributesmodel = m_diagram->attributesModel();
86}
87
88void DiagramObserver::slotDestroyed(QObject *)
89{
90 // qDebug() << this << "emits signal\n"
91 // " Q_EMIT diagramDestroyed(" << m_diagram << ")";
92 AbstractDiagram *diag = m_diagram;
93 disconnect(m_diagram, nullptr, this, nullptr);
94 m_diagram = nullptr;
96}
97
98void DiagramObserver::slotAboutToBeDestroyed()
99{
101}
102
103void DiagramObserver::slotModelsChanged()
104{
105 init();
106 slotDataChanged();
107 slotAttributesChanged();
108}
109
110void DiagramObserver::slotHeaderDataChanged(Qt::Orientation, int, int)
111{
112 // qDebug() << "DiagramObserver::slotHeaderDataChanged()";
113 Q_EMIT diagramDataChanged(m_diagram);
114}
115
116void DiagramObserver::slotDataChanged(QModelIndex, QModelIndex)
117{
118 slotDataChanged();
119}
120
121void DiagramObserver::slotDataChanged()
122{
123 // qDebug() << "DiagramObserver::slotDataChanged()";
124 Q_EMIT diagramDataChanged(m_diagram);
125}
126
127void DiagramObserver::slotDataHidden()
128{
129 // qDebug() << "DiagramObserver::slotDataHidden()";
130 Q_EMIT diagramDataHidden(m_diagram);
131}
132
133void DiagramObserver::slotAttributesChanged(QModelIndex, QModelIndex)
134{
135 slotAttributesChanged();
136}
137
138void DiagramObserver::slotAttributesChanged()
139{
140 // qDebug() << "DiagramObserver::slotAttributesChanged()";
142}
AbstractDiagram defines the interface for diagram classes.
virtual AttributesModel * attributesModel() const
void viewportCoordinateSystemChanged()
void attributesChanged(const QModelIndex &, const QModelIndex &)
const AbstractDiagram * diagram() const
void diagramDataHidden(AbstractDiagram *diagram)
void diagramAboutToBeDestroyed(AbstractDiagram *diagram)
DiagramObserver(AbstractDiagram *diagram, QObject *parent=nullptr)
void diagramDataChanged(AbstractDiagram *diagram)
void diagramDestroyed(AbstractDiagram *diagram)
void diagramAttributesChanged(AbstractDiagram *diagram)
void columnsInserted(const QModelIndex &parent, int first, int last)
void columnsRemoved(const QModelIndex &parent, int first, int last)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
void headerDataChanged(Qt::Orientation orientation, int first, int last)
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsRemoved(const QModelIndex &parent, int first, int last)
QAbstractItemModel * model() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void destroyed(QObject *obj)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
T qobject_cast(QObject *object)
Orientation

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Fri Apr 26 2024 00:04:57 for KD Chart API Documentation by doxygen 1.9.8