emailservices/nmutilities/src/nmcontacthistorymodel.cpp
changeset 76 38bf5461e270
parent 74 6c59112cfd31
equal deleted inserted replaced
74:6c59112cfd31 76:38bf5461e270
    32 NmContactHistoryModel::NmContactHistoryModel(
    32 NmContactHistoryModel::NmContactHistoryModel(
    33     const NmContactHistoryModelType modelType)
    33     const NmContactHistoryModelType modelType)
    34 {
    34 {
    35     NM_FUNCTION;
    35     NM_FUNCTION;
    36     d_ptr = new NmContactHistoryModelPrivate(modelType);
    36     d_ptr = new NmContactHistoryModelPrivate(modelType);
    37 
    37     
    38     QObject::connect(d_ptr, SIGNAL(queryCompleted(int)), this,
    38     QObject::connect(d_ptr, SIGNAL(queryCompleted(int)), this,
    39         SLOT(handleQueryCompleted(int)));
    39         SLOT(handleQueryCompleted(int)));
    40 }
    40 }
    41 
    41 
    42 /*!
    42 /*!
    69 {
    69 {
    70     NM_FUNCTION;
    70     NM_FUNCTION;
    71 
    71 
    72     int lastUpdateIndex = (d_ptr->privateDataCount())-1;
    72     int lastUpdateIndex = (d_ptr->privateDataCount())-1;
    73 
    73 
    74     if (lastUpdateIndex != -1)
    74     if (lastUpdateIndex != -1) {
    75     {
       
    76         // Notify views that we are about to change model data.
    75         // Notify views that we are about to change model data.
    77         beginInsertRows(QModelIndex(),0,lastUpdateIndex);
    76         beginInsertRows(QModelIndex(),0,lastUpdateIndex);
    78         d_ptr->refreshDataModel();
    77         d_ptr->refreshDataModel();
    79         endInsertRows();
    78         endInsertRows();
    80 
    79 
    81         // Emit dataChanged();
    80         // Emit dataChanged();
    82         bool validIndex = hasIndex ( lastUpdateIndex, 0 );
    81         bool validIndex = hasIndex ( lastUpdateIndex, 0 );
    83 
    82 
    84         if (validIndex)
    83         if (validIndex) {
    85         {
       
    86             emit dataChanged(index(0,0), index(lastUpdateIndex,0));
    84             emit dataChanged(index(0,0), index(lastUpdateIndex,0));
    87         }
    85         }
       
    86            
       
    87     }
       
    88     else if (lastUpdateIndex == -1) {
       
    89         beginResetModel();       
       
    90         endResetModel();
    88     }
    91     }
    89 
    92 
    90     emit modelCompleted(err);
    93     emit modelCompleted(err);
    91 }
    94 }
    92 
    95