ui/uiengine/model/mediamodel/inc/glxmediamodel.h
changeset 23 74c9f037fd5d
child 24 99ad1390cd33
equal deleted inserted replaced
5:f7f0874bfe7d 23:74c9f037fd5d
       
     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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef GLXMEDIAMODEL_H
       
    21 #define GLXMEDIAMODEL_H
       
    22 
       
    23 #include <QAbstractItemModel>
       
    24 #include <glxmlwrapper.h>
       
    25 #include <glxuistd.h>
       
    26 #include <QDateTime>
       
    27 #include <glxexternalinterfacedefs.h>
       
    28 //forward declarations
       
    29 
       
    30 #ifdef BUILD_MEDIAMODEL
       
    31 #define GLX_MEDIAMODEL_EXPORT Q_DECL_EXPORT
       
    32 #else
       
    33 #define GLX_MEDIAMODEL_EXPORT Q_DECL_IMPORT
       
    34 #endif
       
    35 
       
    36 class HbIcon;
       
    37 class GlxModelParm;
       
    38 #include <QCache>
       
    39 #include <QVector>
       
    40 
       
    41 class GLX_MEDIAMODEL_EXPORT GlxMediaModel : public QAbstractItemModel
       
    42 {
       
    43 Q_OBJECT
       
    44 public :	
       
    45 	
       
    46     GlxMediaModel(GlxModelParm & modelParm);
       
    47     ~GlxMediaModel();
       
    48     int rowCount(const QModelIndex &parent = QModelIndex()) const;
       
    49     int columnCount(const QModelIndex &parent = QModelIndex()) const;
       
    50     QModelIndex parent(const QModelIndex &child) const;
       
    51     QVariant data(const QModelIndex &index, int role) const;
       
    52     bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
       
    53     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
       
    54 
       
    55 	/*
       
    56 	*for setting external image data to the model. 
       
    57 	*/
       
    58 	void addExternalItems(GlxExternalData* externalItems);
       
    59 	/*
       
    60 	*for removing all external image data from the model. 
       
    61 	*/
       
    62 	void clearExternalItems();
       
    63 	/*
       
    64 	* for checking if the item is editab
       
    65 	*/
       
    66 
       
    67 private:
       
    68 	HbIcon* GetGridIconItem(int itemIndex, GlxTBContextType tbContextType) const;
       
    69 	HbIcon* GetFsIconItem(int itemIndex,GlxTBContextType tbContextType)const;
       
    70 	HbIcon* GetExternalIconItem(int itemIndex,GlxTBContextType tbContextType)const;
       
    71 /**
       
    72  * for setting the attribute context mode will be used mainly for retreiving thumbnail of different sizes.
       
    73  */
       
    74     void setContextMode(GlxContextMode contextMode);
       
    75     void setFocusIndex(const QModelIndex &index);
       
    76     QModelIndex getFocusIndex() const;
       
    77     void setSelectedIndex(const QModelIndex &index);
       
    78 
       
    79 
       
    80 	
       
    81 signals :
       
    82     void iconAvailable(int itemIndex, HbIcon* itemIcon, GlxTBContextType tbContextType) const;
       
    83 public slots:
       
    84 	void itemUpdated1(int mlIndex, GlxTBContextType tbContextType);
       
    85 	void itemsAdded(int startIndex, int endIndex);
       
    86 	void itemsRemoved(int startIndex, int endIndex);
       
    87 	void itemCorrupted(int itemIndex);
       
    88 protected:
       
    89 	
       
    90 private slots:
       
    91     void updateItemIcon(int itemIndex, HbIcon* itemIcon, GlxTBContextType tbContextType);
       
    92 private:
       
    93 	Q_DECL_IMPORT GlxMLWrapper* mMLWrapper;	
       
    94 	QCache<int, HbIcon> itemIconCache;
       
    95 	QCache<int, HbIcon> itemFsIconCache;
       
    96 	HbIcon* m_DefaultIcon;
       
    97 	GlxContextMode mContextMode;
       
    98 	//for external data to be populated by model
       
    99 	GlxExternalData* mExternalItems;
       
   100 	QCache<int, HbIcon> itemExternalIconCache;
       
   101 	int externalDataCount;
       
   102 	int mFocusIndex;
       
   103 };
       
   104 
       
   105 
       
   106 #endif /* GLXMEDIAMODEL_H_ */