phonebookui/cnthistorymodel/inc/cnthistorymodel.h
changeset 31 2a11b5b00470
parent 27 de1630741fbe
child 46 efe85016a067
equal deleted inserted replaced
27:de1630741fbe 31:2a11b5b00470
    42 class CNTHISTORYMODEL_EXPORT CntHistoryModel : public QAbstractListModel
    42 class CNTHISTORYMODEL_EXPORT CntHistoryModel : public QAbstractListModel
    43 {    
    43 {    
    44     Q_OBJECT
    44     Q_OBJECT
    45     
    45     
    46 public:
    46 public:
    47     enum ConversationDirection
    47     enum Attributes
    48         {
    48         {
    49         Incoming = 0,
    49         Incoming = 1,
    50         Outgoing,
    50         Outgoing = 2,
    51         Missed
    51         Unseen = 4,
    52         };
    52         Seen = 8,
    53     
    53         Attachment = 16
    54     enum ReadStatus
       
    55         {
       
    56         Unseen = 3,
       
    57         Seen
       
    58         };
    54         };
    59     
    55     
    60     enum ItemType
    56     enum ItemType
    61         {
    57         {
    62         CallLog = 5,
    58         CallLog = 32,
    63         Message
    59         Message = 64
       
    60         };
       
    61     enum Icon
       
    62         {
       
    63         MissedCall = 128,
       
    64         ReceivedCall = 256,
       
    65         DialledCall = 512
    64         };
    66         };
    65     
    67     
    66     enum CustomRoles
    68     enum CustomRoles
    67         {
    69         {
    68         SeenStatusRole = Qt::UserRole + 1,
    70         FlagsRole = Qt::UserRole + 1,
    69         DirectionRole,
       
    70         ItemTypeRole,
       
    71         PhoneNumberRole
    71         PhoneNumberRole
    72         };
    72         };
    73     
    73     
    74 public:
    74 public:
    75     CntHistoryModel(QContactLocalId contactId,
    75     CntHistoryModel(QContactLocalId contactId,
    86     void sortAndRefresh(Qt::SortOrder order = Qt::AscendingOrder);
    86     void sortAndRefresh(Qt::SortOrder order = Qt::AscendingOrder);
    87     
    87     
    88 private:
    88 private:
    89     void initializeModel();
    89     void initializeModel();
    90     QVariant displayRoleData(const HistoryItem& item) const;
    90     QVariant displayRoleData(const HistoryItem& item) const;
       
    91     QVariant decorationRoleData(const HistoryItem& item) const;
       
    92     QVariant backgroundRoleData(const HistoryItem& item) const;
    91     
    93     
    92     // Utility finctions
    94     // Utility finctions
    93     void readLogEvent(LogsEvent* event, HistoryItem& item);
    95     void readLogEvent(LogsEvent* event, HistoryItem& item);
    94     void readMsgEvent(MsgItem& event, HistoryItem& item);
    96     void readMsgEvent(MsgItem& event, HistoryItem& item);
    95     void initializeLogsModel();
    97     void initializeLogsModel();
   100 private slots:
   102 private slots:
   101     // Logs model slots
   103     // Logs model slots
   102     void logsRowsInserted(const QModelIndex& parent, int first, int last);
   104     void logsRowsInserted(const QModelIndex& parent, int first, int last);
   103     void logsRowsRemoved(const QModelIndex& parent, int first, int last);
   105     void logsRowsRemoved(const QModelIndex& parent, int first, int last);
   104     void logsDataChanged(const QModelIndex& first, const QModelIndex& last);
   106     void logsDataChanged(const QModelIndex& first, const QModelIndex& last);
   105     void clearedCallLogs(int err);
   107     
   106     void markingCompleted(int err);
       
   107     // Messaging model slots
   108     // Messaging model slots
   108     void messagesReady(QList<MsgItem>& msgs);
   109     void messagesReady(QList<MsgItem>& msgs);
   109     void messageAdded(MsgItem& msg);
   110     void messageAdded(MsgItem& msg);
   110     void messageChanged(MsgItem& msg);
   111     void messageChanged(MsgItem& msg);
   111     void messageDeleted(MsgItem& msg);
   112     void messageDeleted(MsgItem& msg);
   112     
   113     
   113 private:
   114 private:
   114 	QSharedDataPointer<CntHistoryModelData> d;
   115 	QSharedDataPointer<CntHistoryModelData> d;
       
   116     
       
   117     // Testing related friend definitions    
       
   118     friend class TestCntHistoryModel;
   115 };
   119 };
   116 #endif
   120 #endif