File indexing completed on 2024-05-12 04:20:32
0001 /* 0002 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef __KCHARTDIAGRAMOBSERVER_H_ 0010 #define __KCHARTDIAGRAMOBSERVER_H_ 0011 0012 #include "KChartGlobal.h" 0013 0014 #include <QObject> 0015 #include <QPointer> 0016 #include <QModelIndex> 0017 0018 QT_BEGIN_NAMESPACE 0019 class QAbstractItemModel; 0020 QT_END_NAMESPACE 0021 0022 namespace KChart { 0023 0024 class AbstractDiagram; 0025 0026 /** 0027 * \brief A DiagramObserver watches the associated diagram for 0028 * changes and deletion and emits corresponding signals. 0029 */ 0030 class KCHART_EXPORT DiagramObserver : public QObject 0031 { 0032 Q_OBJECT 0033 public: 0034 /** 0035 * Constructs a new observer observing the given diagram. 0036 */ 0037 explicit DiagramObserver( AbstractDiagram * diagram, QObject* parent = nullptr ); 0038 ~DiagramObserver() override; 0039 0040 const AbstractDiagram* diagram() const; 0041 AbstractDiagram* diagram(); 0042 0043 Q_SIGNALS: 0044 /** This signal is emitted immediately before the diagram is 0045 * being destroyed. */ 0046 void diagramDestroyed( KChart::AbstractDiagram* diagram ); 0047 /** Emitted when a diagram is being destroyed, but before its data is invalidated **/ 0048 void diagramAboutToBeDestroyed( KChart::AbstractDiagram* diagram ); 0049 /** This signal is emitted whenever the data of the diagram changes. */ 0050 void diagramDataChanged( KChart::AbstractDiagram* diagram ); 0051 /** This signal is emitted whenever any of the data of the diagram was set (un)hidden. */ 0052 void diagramDataHidden( KChart::AbstractDiagram* diagram ); 0053 /** This signal is emitted whenever the attributes of the diagram change. */ 0054 void diagramAttributesChanged( KChart::AbstractDiagram* diagram ); 0055 0056 private Q_SLOTS: 0057 void slotDestroyed(QObject*); 0058 void slotAboutToBeDestroyed(); 0059 void slotHeaderDataChanged(Qt::Orientation,int,int); 0060 void slotDataChanged(QModelIndex,QModelIndex); 0061 void slotDataChanged(); 0062 void slotDataHidden(); 0063 void slotAttributesChanged(); 0064 void slotAttributesChanged(QModelIndex,QModelIndex); 0065 void slotModelsChanged(); 0066 0067 private: 0068 void init(); 0069 0070 AbstractDiagram* m_diagram; 0071 QPointer<QAbstractItemModel> m_model; 0072 QPointer<QAbstractItemModel> m_attributesmodel; 0073 }; 0074 } 0075 0076 #endif // KChartDiagramObserver_H