hgcacheproxymodel/tsrc/unit/dataproviderhelper.cpp
branchGCC_SURGE
changeset 10 c348b9772569
parent 8 15f034b8a3b5
child 20 a60f8b6b1d32
equal deleted inserted replaced
4:463f1934e292 10:c348b9772569
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 *  Version     : %version: 3 %
    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     
   250 QVariant DataProviderHelper::testCreateIcon(int index, QPixmap aPixmap)
   258 QVariant DataProviderHelper::testCreateIcon(int index, QPixmap aPixmap)
   251 {
   259 {
   252     return createIcon(index, aPixmap);
   260     return createIcon(index, aPixmap);
   253 }
   261 }
   254 
   262 
       
   263 void DataProviderHelper::testUpdateIcon(int pos, QVariant icon, bool silent)
       
   264 {
       
   265     updateIcon(pos, icon, silent);
       
   266 }
       
   267 
   255 void DataProviderHelper::testEmitDataChanged(QModelIndex from,QModelIndex to)
   268 void DataProviderHelper::testEmitDataChanged(QModelIndex from,QModelIndex to)
   256 {
   269 {
   257     emit dataChanged(from,to);
   270     emit dataChanged(from,to);
   258 }
   271 }
   259 
   272 
   304 }
   317 }
   305 
   318 
   306 void DataProviderHelper::testEmitModelReset()
   319 void DataProviderHelper::testEmitModelReset()
   307 {
   320 {
   308     endResetModel();
   321     endResetModel();
       
   322 }
       
   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();
   309 }
   365 }
   310 
   366 
   311 void DataProviderHelper::dataUpdated(int from, int to)
   367 void DataProviderHelper::dataUpdated(int from, int to)
   312 {
   368 {
   313     QPair< int, int > p;
   369     QPair< int, int > p;