32 #include <logscustomfilter.h> |
32 #include <logscustomfilter.h> |
33 #endif |
33 #endif |
34 #include <msghistory.h> |
34 #include <msghistory.h> |
35 #include <msgitem.h> |
35 #include <msgitem.h> |
36 #include <hbextendedlocale.h> |
36 #include <hbextendedlocale.h> |
|
37 #include "cnthistorymodel.h" |
|
38 #include "cnthistorymodelconsts.h" |
37 |
39 |
38 QTM_USE_NAMESPACE |
40 QTM_USE_NAMESPACE |
39 |
|
40 // Constants |
|
41 #define MISSED_CALL_ICON "qtg_small_missed_call" |
|
42 #define DAILED_CALL_ICON "qtg_small_sent" |
|
43 #define RECEIVED_CALL_ICON "qtg_small_received" |
|
44 #define MESSAGE_ICON "qtg_small_message" |
|
45 |
41 |
46 class HistoryItem |
42 class HistoryItem |
47 { |
43 { |
48 public: |
44 public: |
49 HistoryItem() : flags(0) |
45 HistoryItem() : flags(0) |
72 QDateTime timeStamp; |
68 QDateTime timeStamp; |
73 }; |
69 }; |
74 |
70 |
75 typedef QSharedPointer<HistoryItem> HItemPointer; |
71 typedef QSharedPointer<HistoryItem> HItemPointer; |
76 |
72 |
77 class CntHistoryModelData : public QSharedData |
73 class CntHistoryModelPrivate : public QObject |
78 { |
74 { |
|
75 Q_OBJECT |
|
76 Q_DECLARE_PUBLIC(CntHistoryModel) |
|
77 |
79 public: |
78 public: |
80 CntHistoryModelData(QContactLocalId contactId, QContactManager* manager) |
79 CntHistoryModelPrivate(QContactLocalId contactId, QContactManager* manager); |
81 : QSharedData(), |
80 ~CntHistoryModelPrivate(); |
82 m_logsModel(NULL), |
81 |
83 m_logsFilter(NULL), |
82 public: |
84 m_AbstractLogsModel(NULL), |
83 QVariant data(const QModelIndex& index, int role) const; |
85 m_msgHistory(NULL), |
84 int rowCount(const QModelIndex& parent = QModelIndex()) const; |
86 m_contactId(contactId), |
85 void sort(int column = 0, Qt::SortOrder order = Qt::AscendingOrder); |
87 m_contactManager(manager), |
86 void clearHistory(); |
88 m_isMyCard(false), |
87 void markAllAsSeen(); |
89 m_isMarkedAsSeen(false), |
88 |
90 m_initLogs(false), |
89 public: |
91 m_extendedLocale(HbExtendedLocale::system()) |
90 CntHistoryModel *q_ptr; |
92 {} |
91 |
93 ~CntHistoryModelData() |
92 public: |
94 { |
93 void initializeModel(); |
95 if (m_logsModel) { |
94 QVariant displayRoleData(const HistoryItem& item) const; |
96 delete m_logsModel; |
95 QVariant decorationRoleData(const HistoryItem& item) const; |
97 m_logsModel = NULL; |
96 QVariant backgroundRoleData(const HistoryItem& item) const; |
98 } |
97 QVariant conversationIdRoleData(const int row) const; |
99 if (m_logsFilter) { |
98 |
100 delete m_logsFilter; |
99 // Utility finctions |
101 m_logsFilter = NULL; |
100 void readLogEvent(LogsEvent* event, HistoryItem& item); |
102 } |
101 void readMsgEvent(MsgItem& event, HistoryItem& item); |
103 if (m_msgHistory) { |
102 void initializeLogsModel(); |
104 delete m_msgHistory; |
103 void initializeMsgModel(); |
105 m_msgHistory = NULL; |
104 bool validateRowIndex(const int index) const; |
106 } |
105 QList< QList<int> > findIndices( const QList< int >& indices ); |
107 }; |
106 |
|
107 public slots: |
|
108 // Logs model slots |
|
109 void logsRowsInserted(const QModelIndex& parent, int first, int last); |
|
110 void logsRowsRemoved(const QModelIndex& parent, int first, int last); |
|
111 void logsDataChanged(const QModelIndex& first, const QModelIndex& last); |
|
112 void handleLogsReset(); |
|
113 |
|
114 // Messaging model slots |
|
115 void messagesReady(QList<MsgItem>& msgs); |
|
116 void messageAdded(MsgItem& msg); |
|
117 void messageChanged(MsgItem& msg); |
|
118 void messageDeleted(MsgItem& msg); |
108 |
119 |
109 public: |
120 public: |
110 LogsModel* m_logsModel; |
121 LogsModel* m_logsModel; |
111 LogsCustomFilter* m_logsFilter; |
122 LogsCustomFilter* m_logsFilter; |
112 QAbstractItemModel* m_AbstractLogsModel; |
123 QAbstractItemModel* m_AbstractLogsModel; |