File indexing completed on 2024-05-12 15:54:15
0001 /* 0002 * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef __KCHARTDIAGRAMOBSERVER_H_ 0021 #define __KCHARTDIAGRAMOBSERVER_H_ 0022 0023 #include "KChartGlobal.h" 0024 0025 #include <QObject> 0026 #include <QPointer> 0027 #include <QModelIndex> 0028 0029 QT_BEGIN_NAMESPACE 0030 class QAbstractItemModel; 0031 QT_END_NAMESPACE 0032 0033 namespace KChart { 0034 0035 class AbstractDiagram; 0036 0037 /** 0038 * \brief A DiagramObserver watches the associated diagram for 0039 * changes and deletion and emits corresponsing signals. 0040 */ 0041 class KCHART_EXPORT DiagramObserver : public QObject 0042 { 0043 Q_OBJECT 0044 public: 0045 /** 0046 * Constructs a new observer observing the given diagram. 0047 */ 0048 explicit DiagramObserver( AbstractDiagram * diagram, QObject* parent = nullptr ); 0049 ~DiagramObserver(); 0050 0051 const AbstractDiagram* diagram() const; 0052 AbstractDiagram* diagram(); 0053 0054 Q_SIGNALS: 0055 /** This signal is emitted immediately before the diagram is 0056 * being destroyed. */ 0057 void diagramDestroyed( AbstractDiagram* diagram ); 0058 /** Emitted when a diagram is being destroyed, but before its data is invalidated **/ 0059 void diagramAboutToBeDestroyed( AbstractDiagram* diagram ); 0060 /** This signal is emitted whenever the data of the diagram changes. */ 0061 void diagramDataChanged( AbstractDiagram* diagram ); 0062 /** This signal is emitted whenever any of the data of the diagram was set (un)hidden. */ 0063 void diagramDataHidden( AbstractDiagram* diagram ); 0064 /** This signal is emitted whenever the attributes of the diagram change. */ 0065 void diagramAttributesChanged( AbstractDiagram* diagram ); 0066 0067 private Q_SLOTS: 0068 void slotDestroyed(QObject*); 0069 void slotAboutToBeDestroyed(); 0070 void slotHeaderDataChanged(Qt::Orientation,int,int); 0071 void slotDataChanged(QModelIndex,QModelIndex); 0072 void slotDataChanged(); 0073 void slotDataHidden(); 0074 void slotAttributesChanged(); 0075 void slotAttributesChanged(QModelIndex,QModelIndex); 0076 void slotModelsChanged(); 0077 0078 private: 0079 void init(); 0080 0081 AbstractDiagram* m_diagram; 0082 QPointer<QAbstractItemModel> m_model; 0083 QPointer<QAbstractItemModel> m_attributesmodel; 0084 }; 0085 } 0086 0087 #endif // KChartDiagramObserver_H