phonebookui/cntcommonui/collections/cntcollectionlistmodel.h
changeset 75 4ecbe3571b5a
equal deleted inserted replaced
71:7cc7d74059f9 75:4ecbe3571b5a
       
     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 CNTCOLLECTIONLISTMODEL_H
       
    19 #define CNTCOLLECTIONLISTMODEL_H
       
    20 
       
    21 #include <QAbstractListModel>
       
    22 #include <QSharedData>
       
    23 #include <qmobilityglobal.h>
       
    24 #include <cntviewparams.h>
       
    25 #include <hbicon.h>
       
    26 #include <xqsettingsmanager.h>
       
    27 
       
    28 class CntCollectionListModelWorker;
       
    29 class CntCollectionListModelData;
       
    30 class CntCollectionItem;
       
    31 
       
    32 class CntExtensionManager;
       
    33 class CntExtensionGroupCallback;
       
    34 class CntAbstractEngine;
       
    35 
       
    36 QTM_USE_NAMESPACE
       
    37 
       
    38 class CntCollectionListModel : public QAbstractListModel
       
    39 {
       
    40     Q_OBJECT
       
    41     
       
    42 public:
       
    43     CntCollectionListModel(CntAbstractEngine* aEngine, QObject *parent = 0);
       
    44     ~CntCollectionListModel();
       
    45     
       
    46 public:
       
    47     // from QAbstractItemModel
       
    48     QVariant data(const QModelIndex& index, int role) const;
       
    49     int rowCount(const QModelIndex& parent = QModelIndex()) const;
       
    50     bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
       
    51     bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
       
    52     
       
    53 public:
       
    54     // removing and adding groups
       
    55     bool removeGroup(int localId);
       
    56     void addGroup(int localId);
       
    57     
       
    58     // extension (plugin) group handling
       
    59     bool isExtensionGroup(const QModelIndex &index);
       
    60     CntViewParameters extensionGroupActivated(int row);
       
    61     void extensionGroupLongPressed(int row, const QPointF& coords, CntExtensionGroupCallback* interface);
       
    62     
       
    63     QModelIndex indexOfGroup(int localId);
       
    64     
       
    65 private:
       
    66     void doConstruct();
       
    67     void initializeStaticGroups();
       
    68     void initializeExtensions();
       
    69     void initializeUserGroups();
       
    70     
       
    71     QVariant displayRoleData(const CntCollectionItem& item) const;
       
    72     QVariant decorationRoleData(const CntCollectionItem& item) const;
       
    73     
       
    74     bool validateRowIndex(const int index) const;
       
    75     
       
    76 private slots:
       
    77     void informationUpdated(int id, const QString& secondRowText, const QList<QContactLocalId>& members);
       
    78     void onIconReady(const QPixmap& pixmap, void *data, int id, int error);
       
    79     void extensionGroupsReady();
       
    80     
       
    81     void handleAdded(const QList<QContactLocalId>& contactIds);
       
    82     void handleRemoved(const QList<QContactLocalId>& contactIds);
       
    83     void handleChanged(const QList<QContactLocalId>& contactIds);
       
    84     void handleAddedRelationship(const QList<QContactLocalId>& contactIds);
       
    85     void handleRemovedRelationship(const QList<QContactLocalId>& contactIds);
       
    86     
       
    87 signals:
       
    88     void groupCountChanged();
       
    89     
       
    90 private:
       
    91     QSharedDataPointer<CntCollectionListModelData>  d;
       
    92     CntCollectionListModelWorker                   *mThread;
       
    93     XQSettingsManager                               mSettings;
       
    94     
       
    95     friend class TestCntCollectionListModel;
       
    96 };
       
    97 
       
    98 #endif // CNTCOLLECTIONLISTMODEL_H