phonebookui/cnthistorymodel/cnthistorymodel_p.h
changeset 81 640d30f4fb64
parent 47 7cbcb2896f0e
equal deleted inserted replaced
77:c18f9fa7f42e 81:640d30f4fb64
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CNTHISTORYMODELPRIVATE_H
       
    19 #define CNTHISTORYMODELPRIVATE_H
       
    20 
       
    21 #include <QSharedData>
       
    22 #include <QSharedPointer>
       
    23 #include <QMap>
       
    24 #include <QDateTime>
       
    25 #include <qtcontacts.h>
       
    26 
       
    27 #ifdef PBK_UNIT_TEST
       
    28 #include "stub_classes.h"
       
    29 #else
       
    30 #include <logsevent.h>
       
    31 #include <logsmodel.h>
       
    32 #include <logscustomfilter.h>
       
    33 #endif
       
    34 #include <msghistory.h>
       
    35 #include <msgitem.h>
       
    36 #include <hbextendedlocale.h>
       
    37 #include "cnthistorymodel.h"
       
    38 #include "cnthistorymodelconsts.h"
       
    39 
       
    40 QTM_USE_NAMESPACE
       
    41 
       
    42 class HistoryItem
       
    43 {   
       
    44 public:   
       
    45     HistoryItem() : flags(0)
       
    46     {};
       
    47     
       
    48     inline const HistoryItem& operator=(const HistoryItem& other)
       
    49     {
       
    50         flags = other.flags;
       
    51         number = other.number;
       
    52         title = other.title;
       
    53         message = other.message;
       
    54         timeStamp = other.timeStamp;
       
    55         return *this;
       
    56     }
       
    57     
       
    58     inline bool operator==(const HistoryItem& other) const
       
    59     {
       
    60          return timeStamp == other.timeStamp;
       
    61     }
       
    62     
       
    63 public:
       
    64     int flags;
       
    65     QString number;
       
    66     QString title;
       
    67     QString message;
       
    68     QDateTime timeStamp;
       
    69 };
       
    70 
       
    71 typedef QSharedPointer<HistoryItem> HItemPointer;
       
    72 
       
    73 class CntHistoryModelPrivate : public QObject
       
    74 {
       
    75     Q_OBJECT
       
    76     Q_DECLARE_PUBLIC(CntHistoryModel)
       
    77     
       
    78 public:
       
    79     CntHistoryModelPrivate(QContactLocalId contactId, QContactManager* manager);
       
    80     ~CntHistoryModelPrivate();
       
    81 
       
    82 public:
       
    83     QVariant data(const QModelIndex& index, int role) const;
       
    84     int rowCount(const QModelIndex& parent = QModelIndex()) const;
       
    85     void sort(int column = 0, Qt::SortOrder order = Qt::AscendingOrder);
       
    86     void clearHistory();
       
    87     void markAllAsSeen();
       
    88     
       
    89 public:
       
    90     CntHistoryModel *q_ptr;
       
    91     
       
    92 public:
       
    93     void initializeModel();
       
    94     QVariant displayRoleData(const HistoryItem& item) const;
       
    95     QVariant decorationRoleData(const HistoryItem& item) const;
       
    96     QVariant backgroundRoleData(const HistoryItem& item) const;
       
    97     QVariant conversationIdRoleData(const int row) const;
       
    98     
       
    99     // Utility finctions
       
   100     void readLogEvent(LogsEvent* event, HistoryItem& item);
       
   101     void readMsgEvent(MsgItem& event, HistoryItem& item);
       
   102     void initializeLogsModel();
       
   103     void initializeMsgModel();
       
   104     bool validateRowIndex(const int index) const;
       
   105     QList< QList<int> > findIndices( const QList< int >& indices );
       
   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);
       
   119     
       
   120 public:
       
   121     LogsModel* m_logsModel;
       
   122     LogsCustomFilter* m_logsFilter;
       
   123     QAbstractItemModel* m_AbstractLogsModel;
       
   124     MsgHistory* m_msgHistory;
       
   125 	QContactLocalId m_contactId;
       
   126     QContactManager* m_contactManager;
       
   127     bool m_isMyCard;
       
   128     bool m_isMarkedAsSeen;
       
   129     bool m_initLogs;
       
   130     //this contains merged calls and messages history
       
   131     QList<HItemPointer> m_List;
       
   132     QMap<int, HItemPointer> m_logsMap;
       
   133     QMap<int, HItemPointer> m_msgMap;
       
   134     const HbExtendedLocale m_extendedLocale;
       
   135 };
       
   136 
       
   137 #endif
       
   138