--- a/ui/uiengine/model/listmodel/src/glxalbummodel.cpp Tue Jul 06 14:16:16 2010 +0300
+++ b/ui/uiengine/model/listmodel/src/glxalbummodel.cpp Wed Aug 18 09:48:53 2010 +0300
@@ -25,14 +25,10 @@
#include "glxicondefs.h" //Contains the icon names/Ids
-const QColor KListOddRowColor(211, 211, 211, 127);
-const QColor KListEvenRowColor(255, 250, 250, 127);
-
-
GlxAlbumModel::GlxAlbumModel(GlxModelParm & modelParm):mContextMode(GlxContextInvalid)
{
qDebug("GlxAlbumModel::GlxAlbumModel()");
-
+ mSubState = -1;
mMLWrapper = new GlxMLWrapper(modelParm.collection(),modelParm.depth(),modelParm.filterType());
// mMLWrapper->setContextMode(GlxContextPtList);
// mContextMode = GlxContextPtList;
@@ -41,6 +37,7 @@
//todo get this Default icon from some generic path and not directly.
mDefaultIcon = new HbIcon(GLXICON_DEFAULT);
+ m_CorruptIcon = new HbIcon( GLXICON_CORRUPT );
int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
qDebug("updateItem() connection status %d", err);
@@ -61,6 +58,7 @@
qDebug("GlxAlbumModel::~GlxAlbumModel()");
delete mDefaultIcon;
mDefaultIcon = NULL;
+ delete m_CorruptIcon;
int err = disconnect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
err = disconnect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
err = disconnect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
@@ -103,6 +101,10 @@
HbIcon* itemIcon = NULL;
QModelIndex idx;
+ if ( role == GlxSubStateRole ){
+ return mSubState;
+ }
+
if ( (!index.isValid()) || (rowIndex >= rowCount()) ) {
return QVariant();
}
@@ -117,7 +119,7 @@
case Qt::DecorationRole :
if(mContextMode == GlxContextSelectionList){
- return HbIcon();
+ return QVariant();
}
else
{
@@ -128,21 +130,10 @@
}
else {
qDebug("GlxAlbumModel::data, Item inValid");
- itemIcon = mDefaultIcon;
+ itemIcon = getCorruptDefaultIcon( index ) ;;
return *itemIcon;
}
}
- case Qt::BackgroundRole:
- {
- if (rowIndex % 2 == 0)
- {
- return QBrush(KListEvenRowColor);
- }
- else
- {
- return QBrush(KListOddRowColor);
- }
- }
case GlxFocusIndexRole :
idx = getFocusIndex();
@@ -160,6 +151,13 @@
return QVariant();
}
}
+HbIcon * GlxAlbumModel::getCorruptDefaultIcon( const QModelIndex &index ) const
+{
+ if ( mMLWrapper->isCorruptedImage( index.row() ) ) {
+ return m_CorruptIcon ;
+ }
+ return mDefaultIcon ;
+}
bool GlxAlbumModel::setData ( const QModelIndex & idx, const QVariant & value, int role )
{
@@ -171,6 +169,11 @@
return TRUE;
}
}
+
+ if ( role == GlxSubStateRole && value.isValid() && value.canConvert <int> ()) {
+ mSubState = value.value <int> () ;
+ return TRUE;
+ }
if ( GlxFocusIndexRole == role ) {
if ( value.isValid() && value.canConvert <int> () ) {
@@ -247,11 +250,18 @@
void GlxAlbumModel::modelPopulated()
{
if ( mTempVisibleWindowIndex!=-1) {
+ //Set the visible Window index only ff the index stored in the activity manager is not out of range
+ if(rowCount() > mTempVisibleWindowIndex && mTempVisibleWindowIndex > 0) {
mMLWrapper->setVisibleWindowIndex(mTempVisibleWindowIndex);
+ }
+ else {
+ mMLWrapper->setVisibleWindowIndex(0);
+ }
mTempVisibleWindowIndex = -1;
+ }
emit listPopulated();
}
-}
+
void GlxAlbumModel::itemUpdated1(int mlIndex,GlxTBContextType tbContextType )
{
Q_UNUSED(tbContextType);
@@ -265,6 +275,7 @@
{
qDebug("GlxAlbumModel::itemsAdded %d %d", startIndex, endIndex);
beginInsertRows(QModelIndex(), startIndex, endIndex);
+ itemIconCache.clear();
endInsertRows();
}
@@ -272,6 +283,7 @@
{
qDebug("GlxAlbumModel::itemsRemoved %d %d", startIndex, endIndex);
beginRemoveRows(QModelIndex(), startIndex, endIndex);
+ itemIconCache.clear();
endRemoveRows();
//emit rowsRemoved(index(startIndex,0), startIndex, endIndex );