hgcacheproxymodel/tsrc/unit/cacheproxyhelper.cpp
changeset 1 e48454f237ca
child 6 1cdcc61142d2
equal deleted inserted replaced
0:89c329efa980 1:e48454f237ca
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 *  Version     : %version: 1 %
       
    17 */
       
    18 #include "cacheproxyhelper.h"
       
    19 
       
    20 CacheProxyHelper::CacheProxyHelper(HgCacheProxyModel *model, QObject *parent):
       
    21 QObject(parent),
       
    22 mModel(model)
       
    23 {
       
    24     ASSERT(mModel!=0);
       
    25     
       
    26     connect(mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
       
    27             this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));
       
    28     
       
    29     connect(mModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
       
    30             this, SLOT(slotHeaderDataChanged(Qt::Orientation,int,int)));
       
    31 
       
    32     connect(mModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
       
    33             this, SLOT(slotRowsAboutToBeInserted(QModelIndex,int,int)));
       
    34 
       
    35     connect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
       
    36             this, SLOT(slotRowsInserted(QModelIndex,int,int)));
       
    37 
       
    38     connect(mModel, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
       
    39             this, SLOT(slotColumnsAboutToBeInserted(QModelIndex,int,int)));
       
    40 
       
    41     connect(mModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
       
    42             this, SLOT(slotColumnsInserted(QModelIndex,int,int)));
       
    43 
       
    44     connect(mModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
       
    45             this, SLOT(slotRowsAboutToBeRemoved(QModelIndex,int,int)));
       
    46 
       
    47     connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
       
    48             this, SLOT(slotRowsRemoved(QModelIndex,int,int)));
       
    49 
       
    50     connect(mModel, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
       
    51             this, SLOT(slotColumnsAboutToBeRemoved(QModelIndex,int,int)));
       
    52 
       
    53     connect(mModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
       
    54             this, SLOT(slotColumnsRemoved(QModelIndex,int,int)));
       
    55 
       
    56     connect(mModel, SIGNAL(layoutAboutToBeChanged()),
       
    57             this, SLOT(slotLayoutAboutToBeChanged()));
       
    58 
       
    59     connect(mModel, SIGNAL(layoutChanged()), 
       
    60             this, SLOT(slotLayoutChanged()));
       
    61 
       
    62     connect(mModel, SIGNAL(modelAboutToBeReset()), 
       
    63             this, SLOT(slotModelAboutToBeReset()));
       
    64     
       
    65     connect(mModel, SIGNAL(modelReset()), 
       
    66             this, SLOT(slotModelReset()));	
       
    67     
       
    68 }
       
    69 
       
    70 CacheProxyHelper::~CacheProxyHelper()
       
    71 {
       
    72     disconnect(mModel);
       
    73 }
       
    74 
       
    75 void CacheProxyHelper::slotDataChanged(QModelIndex from,QModelIndex to)
       
    76 {
       
    77     QPair< int, int > p;
       
    78     p.first = from.row();
       
    79     p.second = to.row();    
       
    80     mSignalDataChanged.append(p);
       
    81 }
       
    82 
       
    83 void CacheProxyHelper::slotHeaderDataChanged(Qt::Orientation orientation, int first, int last)
       
    84 {
       
    85     Q_UNUSED(orientation);    
       
    86     QPair< int, int > p;
       
    87     p.first = first;
       
    88     p.second = last;    
       
    89     mSignalHeaderDataChanged.append(p);
       
    90 }
       
    91 
       
    92 void CacheProxyHelper::slotRowsAboutToBeInserted(QModelIndex parent,int from,int to)
       
    93 {
       
    94     Q_UNUSED(parent);    
       
    95     QPair< int, int > p;
       
    96     p.first = from;
       
    97     p.second = to;    
       
    98     mSignalRowsAboutToBeInserted.append(p);
       
    99 }
       
   100 
       
   101 void CacheProxyHelper::slotRowsInserted(QModelIndex parent,int from,int to)
       
   102 {
       
   103     Q_UNUSED(parent);    
       
   104     QPair< int, int > p;
       
   105     p.first = from;
       
   106     p.second = to;     
       
   107     mSignalRowsInserted.append(p);
       
   108 }
       
   109 
       
   110 void CacheProxyHelper::slotColumnsAboutToBeInserted(QModelIndex parent,int from,int to)
       
   111 {
       
   112     Q_UNUSED(parent);    
       
   113     QPair< int, int > p;
       
   114     p.first = from;
       
   115     p.second = to;    
       
   116     mSignalColumnsAboutToBeInserted.append(p);
       
   117 }
       
   118 
       
   119 void CacheProxyHelper::slotColumnsInserted(QModelIndex parent,int from,int to)
       
   120 {
       
   121     Q_UNUSED(parent);    
       
   122     QPair< int, int > p;
       
   123     p.first = from;
       
   124     p.second = to;      
       
   125     mSignalColumnsInserted.append(p);
       
   126 }
       
   127 
       
   128 void CacheProxyHelper::slotRowsAboutToBeRemoved(QModelIndex parent,int from,int to)
       
   129 {
       
   130     Q_UNUSED(parent);    
       
   131     QPair< int, int > p;
       
   132     p.first = from;
       
   133     p.second = to;      
       
   134     mSignalRowsAboutToBeRemoved.append(p);
       
   135 }
       
   136 
       
   137 void CacheProxyHelper::slotRowsRemoved(QModelIndex parent,int from,int to)
       
   138 {
       
   139     Q_UNUSED(parent);    
       
   140     QPair< int, int > p;
       
   141     p.first = from;
       
   142     p.second = to;       
       
   143     mSignalRowsRemoved.append(p);
       
   144 }
       
   145 
       
   146 void CacheProxyHelper::slotColumnsAboutToBeRemoved(QModelIndex parent,int from,int to)
       
   147 {
       
   148     Q_UNUSED(parent);    
       
   149     QPair< int, int > p;
       
   150     p.first = from;
       
   151     p.second = to;       
       
   152     mSignalColumnsAboutToBeRemoved.append(p);
       
   153 }
       
   154 
       
   155 void CacheProxyHelper::slotColumnsRemoved(QModelIndex parent,int from,int to)
       
   156 {
       
   157     Q_UNUSED(parent);    
       
   158     QPair< int, int > p;
       
   159     p.first = from;
       
   160     p.second = to;       
       
   161     mSignalColumnsRemoved.append(p);
       
   162 }
       
   163 
       
   164 void CacheProxyHelper::slotLayoutAboutToBeChanged()
       
   165 {
       
   166     mSignalLayoutAboutToBeChanged = true;
       
   167 }
       
   168 
       
   169 void CacheProxyHelper::slotLayoutChanged()
       
   170 {
       
   171     mSignalLayoutChanged = true;
       
   172 }
       
   173 
       
   174 void CacheProxyHelper::slotModelAboutToBeReset()
       
   175 {
       
   176     mSignalModelAboutToBeReset = true;
       
   177 }
       
   178 
       
   179 void CacheProxyHelper::slotModelReset()
       
   180 {
       
   181     mSignalModelReset = true;
       
   182 }
       
   183 
       
   184 QList< QPair< int, int > > CacheProxyHelper::getSignalDataChanged()
       
   185 {
       
   186     QList< QPair< int, int > > res = mSignalDataChanged;
       
   187     mSignalDataChanged.clear();
       
   188     return res;
       
   189 }
       
   190 
       
   191 QList< QPair< int, int > > CacheProxyHelper::getSignalHeaderDataChanged()
       
   192 {
       
   193     QList< QPair< int, int > > res = mSignalHeaderDataChanged;
       
   194     mSignalHeaderDataChanged.clear();
       
   195     return res;
       
   196 }
       
   197 
       
   198 QList< QPair< int, int > > CacheProxyHelper::getSignalRowsAboutToBeInserted()
       
   199 {
       
   200     QList< QPair< int, int > > res = mSignalRowsAboutToBeInserted;
       
   201     mSignalRowsAboutToBeInserted.clear();
       
   202     return res;
       
   203 }
       
   204 
       
   205 QList< QPair< int, int > > CacheProxyHelper::getSignalRowsInserted()
       
   206 {
       
   207     QList< QPair< int, int > > res = mSignalRowsInserted;
       
   208     mSignalRowsInserted.clear();
       
   209     return res;
       
   210 }
       
   211 
       
   212 QList< QPair< int, int > > CacheProxyHelper::getSignalColumnsAboutToBeInserted()
       
   213 {
       
   214     QList< QPair< int, int > > res = mSignalColumnsAboutToBeInserted;
       
   215     mSignalColumnsAboutToBeInserted.clear();
       
   216     return res;
       
   217 }
       
   218 
       
   219 QList< QPair< int, int > > CacheProxyHelper::getSignalColumnsInserted()
       
   220 {
       
   221     QList< QPair< int, int > > res = mSignalColumnsInserted;
       
   222     mSignalColumnsInserted.clear();
       
   223     return res;
       
   224 }
       
   225 
       
   226 QList< QPair< int, int > > CacheProxyHelper::getSignalRowsAboutToBeRemoved()
       
   227 {
       
   228     QList< QPair< int, int > > res = mSignalRowsAboutToBeRemoved;
       
   229     mSignalRowsAboutToBeRemoved.clear();
       
   230     return res;
       
   231 }
       
   232 
       
   233 QList< QPair< int, int > > CacheProxyHelper::getSignalRowsRemoved()
       
   234 {
       
   235     QList< QPair< int, int > > res = mSignalRowsRemoved;
       
   236     mSignalRowsRemoved.clear();
       
   237     return res;
       
   238 }
       
   239 
       
   240 QList< QPair< int, int > > CacheProxyHelper::getSignalColumnsAboutToBeRemoved()
       
   241 {
       
   242     QList< QPair< int, int > > res = mSignalColumnsAboutToBeRemoved;
       
   243     mSignalColumnsAboutToBeRemoved.clear();
       
   244     return res;
       
   245 }
       
   246 
       
   247 QList< QPair< int, int > > CacheProxyHelper::getSignalColumnsRemoved()
       
   248 {
       
   249     QList< QPair< int, int > > res = mSignalColumnsRemoved;
       
   250     mSignalColumnsRemoved.clear();
       
   251     return res;
       
   252 }
       
   253 
       
   254 bool CacheProxyHelper::getSignalLayoutAboutToBeChanged()
       
   255 {
       
   256     bool res = mSignalLayoutAboutToBeChanged;
       
   257     mSignalLayoutAboutToBeChanged = false;
       
   258     return res;
       
   259 }
       
   260 
       
   261 bool CacheProxyHelper::getSignalLayoutChanged()
       
   262 {
       
   263     bool res = mSignalLayoutChanged;
       
   264     mSignalLayoutChanged = false;
       
   265     return res;
       
   266 }
       
   267 
       
   268 bool CacheProxyHelper::getSignalModelAboutToBeReset()
       
   269 {
       
   270     bool res = mSignalModelAboutToBeReset;
       
   271     mSignalModelAboutToBeReset = false;
       
   272     return res;
       
   273 }
       
   274 
       
   275 bool CacheProxyHelper::getSignalModelReset()
       
   276 {
       
   277     bool res = mSignalModelReset;
       
   278     mSignalModelReset = false;
       
   279     return res;
       
   280 }
       
   281 
       
   282 
       
   283 
       
   284