phonebookui/cnthistorymodel/src/cnthistorymodel.cpp
changeset 71 7cc7d74059f9
parent 47 7cbcb2896f0e
equal deleted inserted replaced
65:ae724a111993 71:7cc7d74059f9
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "cnthistorymodel_p.h"
    18 #include "cnthistorymodel_p.h"
    19 #include "cnthistorymodel.h"
    19 #include "cnthistorymodel.h"
       
    20 #include "cntdebug.h"
    20 
    21 
    21 /*!
    22 /*!
    22  * Construct a new CntHistoryModel object to communicate 
    23  * Construct a new CntHistoryModel object to communicate 
    23  * with the conversations and logs databases.
    24  * with the conversations and logs databases.
    24  *
    25  *
    30                                  QContactManager* manager,
    31                                  QContactManager* manager,
    31                                  QObject *parent)
    32                                  QObject *parent)
    32     : QAbstractListModel(parent),
    33     : QAbstractListModel(parent),
    33       d_ptr(new CntHistoryModelPrivate(contactId, manager))
    34       d_ptr(new CntHistoryModelPrivate(contactId, manager))
    34 {
    35 {
       
    36     CNT_ENTRY
       
    37     
    35     Q_D(CntHistoryModel);
    38     Q_D(CntHistoryModel);
    36     d->q_ptr = this;
    39     d->q_ptr = this;
       
    40     
       
    41     CNT_EXIT
    37 }
    42 }
    38 
    43 
    39 CntHistoryModel::~CntHistoryModel()
    44 CntHistoryModel::~CntHistoryModel()
    40 {
    45 {
       
    46     CNT_ENTRY
       
    47     
    41     Q_D(CntHistoryModel);
    48     Q_D(CntHistoryModel);
    42     delete d;
    49     delete d;
       
    50     
       
    51     CNT_EXIT
    43 }
    52 }
    44 
    53 
    45 /*!
    54 /*!
    46  * Return the data to be used by the view or delegates for a particular
    55  * Return the data to be used by the view or delegates for a particular
    47  * item and role.
    56  * item and role.
    67     Q_D(const CntHistoryModel);
    76     Q_D(const CntHistoryModel);
    68     return d->rowCount(parent);
    77     return d->rowCount(parent);
    69 }
    78 }
    70 
    79 
    71 /*!
    80 /*!
    72  * Sort list items on the model.
       
    73  *
       
    74  * \param column Column to be sorted. It is not used.
       
    75  * \param order Order to sort the list items.
       
    76  */
       
    77 void CntHistoryModel::sort(int column, Qt::SortOrder order)
       
    78 {
       
    79     Q_D(CntHistoryModel);
       
    80     d->sort(column, order);
       
    81 }
       
    82 
       
    83 /*!
       
    84  * Clear history from the database. If the history cached
    81  * Clear history from the database. If the history cached
    85  * is specific to one contact, only that history is cleared.
    82  * is specific to one contact, only that history is cleared.
    86  * 
    83  * 
    87  */
    84  */
    88 void CntHistoryModel::clearHistory()
    85 void CntHistoryModel::clearHistory()
    89 {    
    86 {
    90     Q_D(CntHistoryModel);    
    87     CNT_ENTRY
       
    88     
       
    89     Q_D(CntHistoryModel);
    91     d->clearHistory();
    90     d->clearHistory();
       
    91     
       
    92     CNT_EXIT
    92 }
    93 }
    93 
    94 
    94 /*!
    95 /*!
    95  * Mark all the conversations in the view as seen.
    96  * Mark all the conversations in the view as seen.
    96  * 
    97  * 
    97  */
    98  */
    98 void CntHistoryModel::markAllAsSeen()
    99 void CntHistoryModel::markAllAsSeen()
    99 {
   100 {
       
   101     CNT_ENTRY
       
   102     
   100     Q_D(CntHistoryModel);
   103     Q_D(CntHistoryModel);
   101     d->markAllAsSeen();
   104     d->markAllAsSeen();
       
   105     
       
   106     CNT_EXIT
   102 }
   107 }
   103 
   108 
   104 /*!
   109 /*!
   105  * Sort items in the model and refresh the view
   110  * Sort items in the model and refresh the view
   106  * 
   111  *
       
   112  * \param order Order to sort the list items.
   107  */
   113  */
   108 void CntHistoryModel::sortAndRefresh(Qt::SortOrder order)
   114 void CntHistoryModel::sortAndRefresh(Qt::SortOrder order)
   109 {
   115 {
       
   116     CNT_ENTRY_ARGS(order)
       
   117     
   110     Q_D(CntHistoryModel);
   118     Q_D(CntHistoryModel);
       
   119     
       
   120     doBeginResetModel();
   111     d->sort(order);
   121     d->sort(order);
   112     beginInsertRows(QModelIndex(), 0, rowCount());
   122     doEndResetModel();
   113     endInsertRows();
   123     
       
   124     CNT_EXIT
   114 }
   125 }
   115 
   126 
   116 void CntHistoryModel::doBeginInsertRows(const QModelIndex &parent, int first, int last)
   127 void CntHistoryModel::doBeginInsertRows(const QModelIndex &parent, int first, int last)
   117 {
   128 {
       
   129     CNT_ENTRY_ARGS(parent << first << last)
       
   130     
   118     beginInsertRows(parent, first, last);
   131     beginInsertRows(parent, first, last);
       
   132     
       
   133     CNT_EXIT
       
   134 }
       
   135 
       
   136 void CntHistoryModel::doEndInsertRows()
       
   137 {
       
   138     CNT_ENTRY
       
   139     
       
   140     endInsertRows();
       
   141     
       
   142     CNT_EXIT
       
   143 }
       
   144 
       
   145 void CntHistoryModel::doBeginRemoveRows(const QModelIndex &parent, int first, int last)
       
   146 {
       
   147     CNT_ENTRY_ARGS(parent << first << last)
       
   148     
       
   149     beginRemoveRows(parent, first, last);
       
   150     
       
   151     CNT_EXIT
   119 }
   152 }
   120 
   153 
   121 void CntHistoryModel::doEndRemoveRows()
   154 void CntHistoryModel::doEndRemoveRows()
   122 {
   155 {
       
   156     CNT_ENTRY
       
   157     
   123     endRemoveRows();
   158     endRemoveRows();
       
   159     
       
   160     CNT_EXIT
   124 }
   161 }
   125 
   162 
   126 void CntHistoryModel::doBeginRemoveRows(const QModelIndex &parent, int first, int last)
   163 void CntHistoryModel::doBeginResetModel()
   127 {
   164 {
   128     beginRemoveRows(parent, first, last);
   165     CNT_ENTRY
       
   166     
       
   167     beginResetModel();
       
   168     
       
   169     CNT_EXIT
   129 }
   170 }
   130 
   171 
   131 void CntHistoryModel::doEndInsertRows()
   172 void CntHistoryModel::doEndResetModel()
   132 {
   173 {
   133     endInsertRows();
   174     CNT_ENTRY
       
   175     
       
   176     endResetModel();
       
   177     
       
   178     CNT_EXIT
   134 }
   179 }
   135 
   180 
   136 void CntHistoryModel::doDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
   181 void CntHistoryModel::doDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
   137 {
   182 {
       
   183     CNT_ENTRY_ARGS(topLeft << bottomRight)
       
   184     
   138     emit dataChanged(topLeft, bottomRight);
   185     emit dataChanged(topLeft, bottomRight);
       
   186     
       
   187     CNT_EXIT
   139 }
   188 }