23 #include <QBrush> |
23 #include <QBrush> |
24 #include <glxmlwrapper.h> |
24 #include <glxmlwrapper.h> |
25 |
25 |
26 #include "glxicondefs.h" //Contains the icon names/Ids |
26 #include "glxicondefs.h" //Contains the icon names/Ids |
27 |
27 |
28 const QColor KListOddRowColor(211, 211, 211, 127); |
|
29 const QColor KListEvenRowColor(255, 250, 250, 127); |
|
30 |
|
31 |
|
32 GlxAlbumModel::GlxAlbumModel(GlxModelParm & modelParm):mContextMode(GlxContextInvalid) |
28 GlxAlbumModel::GlxAlbumModel(GlxModelParm & modelParm):mContextMode(GlxContextInvalid) |
33 { |
29 { |
34 qDebug("GlxAlbumModel::GlxAlbumModel()"); |
30 qDebug("GlxAlbumModel::GlxAlbumModel()"); |
35 |
31 |
36 mMLWrapper = new GlxMLWrapper(modelParm.collection(),modelParm.depth(),modelParm.filterType()); |
32 mMLWrapper = new GlxMLWrapper(modelParm.collection(),modelParm.depth(),modelParm.filterType()); |
39 mMLWrapper->setContextMode(GlxContextSelectionList); |
35 mMLWrapper->setContextMode(GlxContextSelectionList); |
40 mContextMode = GlxContextSelectionList; |
36 mContextMode = GlxContextSelectionList; |
41 |
37 |
42 //todo get this Default icon from some generic path and not directly. |
38 //todo get this Default icon from some generic path and not directly. |
43 mDefaultIcon = new HbIcon(GLXICON_DEFAULT); |
39 mDefaultIcon = new HbIcon(GLXICON_DEFAULT); |
|
40 m_CorruptIcon = new HbIcon( GLXICON_CORRUPT ); |
44 |
41 |
45 int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType))); |
42 int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType))); |
46 qDebug("updateItem() connection status %d", err); |
43 qDebug("updateItem() connection status %d", err); |
47 err = connect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int))); |
44 err = connect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int))); |
48 qDebug("insertItems() connection status %d", err); |
45 qDebug("insertItems() connection status %d", err); |
59 GlxAlbumModel::~GlxAlbumModel() |
56 GlxAlbumModel::~GlxAlbumModel() |
60 { |
57 { |
61 qDebug("GlxAlbumModel::~GlxAlbumModel()"); |
58 qDebug("GlxAlbumModel::~GlxAlbumModel()"); |
62 delete mDefaultIcon; |
59 delete mDefaultIcon; |
63 mDefaultIcon = NULL; |
60 mDefaultIcon = NULL; |
|
61 delete m_CorruptIcon; |
64 int err = disconnect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType))); |
62 int err = disconnect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType))); |
65 err = disconnect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int))); |
63 err = disconnect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int))); |
66 err = disconnect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int))); |
64 err = disconnect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int))); |
67 err = disconnect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType))); |
65 err = disconnect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType))); |
68 err = disconnect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelPopulated())); |
66 err = disconnect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelPopulated())); |
115 } |
113 } |
116 return text; |
114 return text; |
117 |
115 |
118 case Qt::DecorationRole : |
116 case Qt::DecorationRole : |
119 if(mContextMode == GlxContextSelectionList){ |
117 if(mContextMode == GlxContextSelectionList){ |
120 return HbIcon(); |
118 return QVariant(); |
121 } |
119 } |
122 else |
120 else |
123 { |
121 { |
124 itemIcon = GetPreviewIconItem(rowIndex,GlxTBContextGrid); |
122 itemIcon = GetPreviewIconItem(rowIndex,GlxTBContextGrid); |
125 if(itemIcon){ |
123 if(itemIcon){ |
126 qDebug("GlxAlbumModel::data, Item Valid"); |
124 qDebug("GlxAlbumModel::data, Item Valid"); |
127 return *itemIcon; |
125 return *itemIcon; |
128 } |
126 } |
129 else { |
127 else { |
130 qDebug("GlxAlbumModel::data, Item inValid"); |
128 qDebug("GlxAlbumModel::data, Item inValid"); |
131 itemIcon = mDefaultIcon; |
129 itemIcon = getCorruptDefaultIcon( index ) ;; |
132 return *itemIcon; |
130 return *itemIcon; |
133 } |
|
134 } |
|
135 case Qt::BackgroundRole: |
|
136 { |
|
137 if (rowIndex % 2 == 0) |
|
138 { |
|
139 return QBrush(KListEvenRowColor); |
|
140 } |
|
141 else |
|
142 { |
|
143 return QBrush(KListOddRowColor); |
|
144 } |
131 } |
145 } |
132 } |
146 |
133 |
147 case GlxFocusIndexRole : |
134 case GlxFocusIndexRole : |
148 idx = getFocusIndex(); |
135 idx = getFocusIndex(); |
158 |
145 |
159 default : |
146 default : |
160 return QVariant(); |
147 return QVariant(); |
161 } |
148 } |
162 } |
149 } |
|
150 HbIcon * GlxAlbumModel::getCorruptDefaultIcon( const QModelIndex &index ) const |
|
151 { |
|
152 if ( mMLWrapper->isCorruptedImage( index.row() ) ) { |
|
153 return m_CorruptIcon ; |
|
154 } |
|
155 return mDefaultIcon ; |
|
156 } |
163 |
157 |
164 bool GlxAlbumModel::setData ( const QModelIndex & idx, const QVariant & value, int role ) |
158 bool GlxAlbumModel::setData ( const QModelIndex & idx, const QVariant & value, int role ) |
165 { |
159 { |
166 Q_UNUSED( idx ) |
160 Q_UNUSED( idx ) |
167 qDebug("GlxAlbumModel::setData context role %d value %d", role, value.value <int> ()); |
161 qDebug("GlxAlbumModel::setData context role %d value %d", role, value.value <int> ()); |
245 } |
239 } |
246 |
240 |
247 void GlxAlbumModel::modelPopulated() |
241 void GlxAlbumModel::modelPopulated() |
248 { |
242 { |
249 if ( mTempVisibleWindowIndex!=-1) { |
243 if ( mTempVisibleWindowIndex!=-1) { |
|
244 //Set the visible Window index only ff the index stored in the activity manager is not out of range |
|
245 if(rowCount() > mTempVisibleWindowIndex && mTempVisibleWindowIndex > 0) { |
250 mMLWrapper->setVisibleWindowIndex(mTempVisibleWindowIndex); |
246 mMLWrapper->setVisibleWindowIndex(mTempVisibleWindowIndex); |
|
247 } |
|
248 else { |
|
249 mMLWrapper->setVisibleWindowIndex(0); |
|
250 } |
251 mTempVisibleWindowIndex = -1; |
251 mTempVisibleWindowIndex = -1; |
|
252 } |
252 emit listPopulated(); |
253 emit listPopulated(); |
253 } |
254 } |
254 } |
255 |
255 void GlxAlbumModel::itemUpdated1(int mlIndex,GlxTBContextType tbContextType ) |
256 void GlxAlbumModel::itemUpdated1(int mlIndex,GlxTBContextType tbContextType ) |
256 { |
257 { |
257 Q_UNUSED(tbContextType); |
258 Q_UNUSED(tbContextType); |
258 qDebug("GlxAlbumModel::itemUpdated %d", mlIndex); |
259 qDebug("GlxAlbumModel::itemUpdated %d", mlIndex); |
259 |
260 |