File indexing completed on 2024-05-12 15:54:18

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 #include "KChartModelDataCache_p.h"
0021 
0022 #include <limits>
0023 
0024 using namespace KChart::ModelDataCachePrivate;
0025 
0026 ModelSignalMapperConnector::ModelSignalMapperConnector( ModelSignalMapper& mapper )
0027     : QObject( nullptr ),
0028       m_mapper( mapper )
0029 {
0030 }
0031 
0032 ModelSignalMapperConnector::~ModelSignalMapperConnector()
0033 {
0034 }
0035 
0036 void ModelSignalMapperConnector::connectSignals( QAbstractItemModel* model )
0037 {
0038     connect( model, SIGNAL(destroyed()),                              this, SLOT(resetModel()) );
0039     connect( model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(columnsInserted(QModelIndex,int,int)) );
0040     connect( model, SIGNAL(columnsRemoved(QModelIndex,int,int)),  this, SLOT(columnsRemoved(QModelIndex,int,int)) );
0041     connect( model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),  this, SLOT(dataChanged(QModelIndex,QModelIndex)) );
0042     connect( model, SIGNAL(layoutChanged()),                          this, SLOT(layoutChanged()) );
0043     connect( model, SIGNAL(modelReset()),                             this, SLOT(modelReset()) );
0044     connect( model, SIGNAL(rowsInserted(QModelIndex,int,int)),    this, SLOT(rowsInserted(QModelIndex,int,int)) );
0045     connect( model, SIGNAL(rowsRemoved(QModelIndex,int,int)),     this, SLOT(rowsRemoved(QModelIndex,int,int)) );
0046 }
0047 
0048 void ModelSignalMapperConnector::disconnectSignals( QAbstractItemModel* model )
0049 {
0050     disconnect( model, SIGNAL(destroyed()),                              this, SLOT(resetModel()) );
0051     disconnect( model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(columnsInserted(QModelIndex,int,int)) );
0052     disconnect( model, SIGNAL(columnsRemoved(QModelIndex,int,int)),  this, SLOT(columnsRemoved(QModelIndex,int,int)) );
0053     disconnect( model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),  this, SLOT(dataChanged(QModelIndex,QModelIndex)) );
0054     disconnect( model, SIGNAL(layoutChanged()),                          this, SLOT(layoutChanged()) );
0055     disconnect( model, SIGNAL(modelReset()),                             this, SLOT(modelReset()) );
0056     disconnect( model, SIGNAL(rowsInserted(QModelIndex,int,int)),    this, SLOT(rowsInserted(QModelIndex,int,int)) );
0057     disconnect( model, SIGNAL(rowsRemoved(QModelIndex,int,int)),     this, SLOT(rowsRemoved(QModelIndex,int,int)) );
0058 }
0059 
0060 void ModelSignalMapperConnector::resetModel()
0061 {
0062     m_mapper.resetModel();
0063 }
0064 
0065 void ModelSignalMapperConnector::columnsInserted( const QModelIndex& parent, int start, int end )
0066 {
0067     m_mapper.columnsInserted( parent, start, end );
0068 }
0069 
0070 void ModelSignalMapperConnector::columnsRemoved( const QModelIndex& parent, int start, int end )
0071 {
0072     m_mapper.columnsRemoved( parent, start, end );
0073 }
0074 
0075 void ModelSignalMapperConnector::dataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight )
0076 {
0077     m_mapper.dataChanged( topLeft, bottomRight );
0078 }
0079 
0080 void ModelSignalMapperConnector::layoutChanged()
0081 {
0082     m_mapper.layoutChanged();
0083 }
0084 
0085 void ModelSignalMapperConnector::modelReset()
0086 {
0087     m_mapper.modelReset();
0088 }
0089 
0090 void ModelSignalMapperConnector::rowsInserted( const QModelIndex& parent, int start, int end )
0091 {
0092     m_mapper.rowsInserted( parent, start, end );
0093 }
0094 
0095 void ModelSignalMapperConnector::rowsRemoved( const QModelIndex& parent, int start, int end )
0096 {
0097     m_mapper.rowsRemoved( parent, start, end );
0098 }