hgcacheproxymodel/tsrc/unit/dataproviderhelper.cpp
changeset 6 1cdcc61142d2
parent 3 c863538fcbb6
child 20 a60f8b6b1d32
equal deleted inserted replaced
5:4fa04caf0f43 6:1cdcc61142d2
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 *  Version     : %version: 5 %
    16 *  Version     : %version: 6 %
    17 */
    17 */
    18 #include "dataproviderhelper.h"
    18 #include "dataproviderhelper.h"
    19 #include <QtDebug>
    19 #include <QtDebug>
       
    20 #include <QtTest/QtTest>
    20 
    21 
    21 const int KRole1 = Qt::UserRole+1;
    22 const int KRole1 = Qt::UserRole+1;
    22 const int KRole2 = Qt::UserRole+2;
    23 const int KRole2 = Qt::UserRole+2;
    23 const int KRole3 = Qt::UserRole+3;
    24 const int KRole3 = Qt::UserRole+3;
    24 
    25 
    41         list.append( QPair< QVariant, int >(QVariant(b), KRole2) );
    42         list.append( QPair< QVariant, int >(QVariant(b), KRole2) );
    42         list.append( QPair< QVariant, int >(QVariant(c), KRole3) );
    43         list.append( QPair< QVariant, int >(QVariant(c), KRole3) );
    43         newItem(&list, true);
    44         newItem(&list, true);
    44     }
    45     }
    45     
    46     
    46     connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
    47     bool res = connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
    47             this, SLOT(slotDataUpdated(QModelIndex,QModelIndex)));
    48                         this, SLOT(slotDataUpdated(QModelIndex,QModelIndex)));
    48     
    49     QCOMPARE(res, true);
    49     connect(this, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
    50     
    50             this, SLOT(slotRowsAboutToBeInserted(QModelIndex,int,int)));
    51     res = connect(this, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
    51 
    52                     this, SLOT(slotRowsAboutToBeInserted(QModelIndex,int,int)));
    52     connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)),
    53     QCOMPARE(res, true);
    53             this, SLOT(slotRowsInserted(QModelIndex,int,int)));    
    54     
    54     
    55     res = connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)),
    55     connect(this, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
    56                     this, SLOT(slotRowsInserted(QModelIndex,int,int)));    
    56             this, SLOT(slotRowsAboutToBeRemoved(QModelIndex,int,int)));
    57     QCOMPARE(res, true);
    57 
    58     
    58     connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)),
    59     res = connect(this, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
    59             this, SLOT(slotRowsRemoved(QModelIndex,int,int)));    
    60                     this, SLOT(slotRowsAboutToBeRemoved(QModelIndex,int,int)));
    60     
    61     QCOMPARE(res, true);
    61     connect(this, SIGNAL(modelAboutToBeReset()), 
    62     
    62             this, SLOT(slotModelAboutToBeReset()));
    63     res = connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)),
    63     
    64                     this, SLOT(slotRowsRemoved(QModelIndex,int,int)));    
    64     connect(this, SIGNAL(modelReset()), 
    65     QCOMPARE(res, true);
    65             this, SLOT(slotModelReset()));
    66     
       
    67     res = connect(this, SIGNAL(modelAboutToBeReset()), 
       
    68                     this, SLOT(slotModelAboutToBeReset()));
       
    69     QCOMPARE(res, true);
       
    70     
       
    71     res = connect(this, SIGNAL(modelReset()), 
       
    72                 this, SLOT(slotModelReset()));
       
    73     QCOMPARE(res, true);    
    66 }
    74 }
    67 
    75 
    68 DataProviderHelper::~DataProviderHelper()
    76 DataProviderHelper::~DataProviderHelper()
    69 {
    77 {
    70     
    78     
   311 void DataProviderHelper::testEmitModelReset()
   319 void DataProviderHelper::testEmitModelReset()
   312 {
   320 {
   313     endResetModel();
   321     endResetModel();
   314 }
   322 }
   315 
   323 
       
   324 bool DataProviderHelper::testEmitColumnsAboutToBeMoved(int from, int to)
       
   325 {
       
   326     return beginMoveColumns(parent(index(0,0)), from, to, parent(index(0,0)), 0);
       
   327 }
       
   328 
       
   329 void DataProviderHelper::testEmitColumnsMoved(int from, int to)
       
   330 {
       
   331     endMoveColumns();
       
   332 }
       
   333 
       
   334 bool DataProviderHelper::testEmitRowsAboutToBeMoved(int from, int to)
       
   335 {
       
   336     return beginMoveRows(parent(index(0,0)), from, to, parent(index(0,0)), 0);
       
   337 }
       
   338 
       
   339 void DataProviderHelper::testEmitRowsMoved(int from, int to)
       
   340 {
       
   341     endMoveRows();
       
   342 }
       
   343 
       
   344 void DataProviderHelper::testChangeIconMode(HgDataProviderModel::HgDataProviderIconMode mode)
       
   345 {
       
   346     setIconMode(mode);
       
   347 }
       
   348 
       
   349 HgDataProviderModel::HgDataProviderIconMode DataProviderHelper::testIconMode()
       
   350 {
       
   351     return iconMode();
       
   352 }
       
   353 
       
   354 void DataProviderHelper::testClearItem(int pos, bool silent )
       
   355 {
       
   356     clearItem(pos, silent);
       
   357 }
       
   358 QModelIndex DataProviderHelper::testCreateIndex(int row, int col)
       
   359 {
       
   360     return createIndex(row, col);
       
   361 }
       
   362 int DataProviderHelper::getCount()
       
   363 {
       
   364     return count();
       
   365 }
       
   366 
   316 void DataProviderHelper::dataUpdated(int from, int to)
   367 void DataProviderHelper::dataUpdated(int from, int to)
   317 {
   368 {
   318     QPair< int, int > p;
   369     QPair< int, int > p;
   319     p.first = from;
   370     p.first = from;
   320     p.second = to;    
   371     p.second = to;