File indexing completed on 2024-05-12 04:20:35
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 #include "KChartModelDataCache_p.h" 0010 0011 0012 using namespace KChart::ModelDataCachePrivate; 0013 0014 ModelSignalMapperConnector::ModelSignalMapperConnector( ModelSignalMapper& mapper ) 0015 : QObject( nullptr ), 0016 m_mapper( mapper ) 0017 { 0018 } 0019 0020 ModelSignalMapperConnector::~ModelSignalMapperConnector() 0021 { 0022 } 0023 0024 void ModelSignalMapperConnector::connectSignals( QAbstractItemModel* model ) 0025 { 0026 connect( model, SIGNAL(destroyed()), this, SLOT(resetModel()) ); 0027 connect( model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(columnsInserted(QModelIndex,int,int)) ); 0028 connect( model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(columnsRemoved(QModelIndex,int,int)) ); 0029 connect( model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex)) ); 0030 connect( model, SIGNAL(layoutChanged()), this, SLOT(layoutChanged()) ); 0031 connect( model, SIGNAL(modelReset()), this, SLOT(modelReset()) ); 0032 connect( model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int)) ); 0033 connect( model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int)) ); 0034 } 0035 0036 void ModelSignalMapperConnector::disconnectSignals( QAbstractItemModel* model ) 0037 { 0038 disconnect( model, SIGNAL(destroyed()), this, SLOT(resetModel()) ); 0039 disconnect( model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(columnsInserted(QModelIndex,int,int)) ); 0040 disconnect( model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(columnsRemoved(QModelIndex,int,int)) ); 0041 disconnect( model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex)) ); 0042 disconnect( model, SIGNAL(layoutChanged()), this, SLOT(layoutChanged()) ); 0043 disconnect( model, SIGNAL(modelReset()), this, SLOT(modelReset()) ); 0044 disconnect( model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int)) ); 0045 disconnect( model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int)) ); 0046 } 0047 0048 void ModelSignalMapperConnector::resetModel() 0049 { 0050 m_mapper.resetModel(); 0051 } 0052 0053 void ModelSignalMapperConnector::columnsInserted( const QModelIndex& parent, int start, int end ) 0054 { 0055 m_mapper.columnsInserted( parent, start, end ); 0056 } 0057 0058 void ModelSignalMapperConnector::columnsRemoved( const QModelIndex& parent, int start, int end ) 0059 { 0060 m_mapper.columnsRemoved( parent, start, end ); 0061 } 0062 0063 void ModelSignalMapperConnector::dataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight ) 0064 { 0065 m_mapper.dataChanged( topLeft, bottomRight ); 0066 } 0067 0068 void ModelSignalMapperConnector::layoutChanged() 0069 { 0070 m_mapper.layoutChanged(); 0071 } 0072 0073 void ModelSignalMapperConnector::modelReset() 0074 { 0075 m_mapper.modelReset(); 0076 } 0077 0078 void ModelSignalMapperConnector::rowsInserted( const QModelIndex& parent, int start, int end ) 0079 { 0080 m_mapper.rowsInserted( parent, start, end ); 0081 } 0082 0083 void ModelSignalMapperConnector::rowsRemoved( const QModelIndex& parent, int start, int end ) 0084 { 0085 m_mapper.rowsRemoved( parent, start, end ); 0086 }