equal
deleted
inserted
replaced
17 |
17 |
18 #include <hbicon.h> |
18 #include <hbicon.h> |
19 |
19 |
20 #include "irchannelmodel.h" |
20 #include "irchannelmodel.h" |
21 #include "irqisdsdatastructure.h" |
21 #include "irqisdsdatastructure.h" |
|
22 #include "irsearchresultdb.h" |
22 |
23 |
23 IrChannelModel::IrChannelModel(QObject *aParent): QAbstractListModel(aParent) |
24 IrChannelModel::IrChannelModel(QObject *aParent): QAbstractListModel(aParent) |
24 , iChannelList(NULL) |
25 , iChannelList(NULL),iDB(NULL) |
25 { |
26 { |
26 iStationLogo = new HbIcon("qtg_large_internet_radio"); |
27 iStationLogo = new HbIcon("qtg_large_internet_radio"); |
27 } |
28 } |
28 |
29 |
29 IrChannelModel::~IrChannelModel() |
30 IrChannelModel::~IrChannelModel() |
32 |
33 |
33 delete iStationLogo; |
34 delete iStationLogo; |
34 iStationLogo = NULL; |
35 iStationLogo = NULL; |
35 |
36 |
36 clearAndDestroyLogos(); |
37 clearAndDestroyLogos(); |
|
38 |
|
39 if( iDB ) |
|
40 { |
|
41 delete iDB; |
|
42 iDB = NULL; |
|
43 } |
37 } |
44 } |
38 |
45 |
39 int IrChannelModel::rowCount(const QModelIndex &aParent) const |
46 int IrChannelModel::rowCount(const QModelIndex &aParent) const |
40 { |
47 { |
41 Q_UNUSED(aParent); |
48 Q_UNUSED(aParent); |
123 clearAndDestroyLogos(); |
130 clearAndDestroyLogos(); |
124 |
131 |
125 emit dataAvailable(); |
132 emit dataAvailable(); |
126 } |
133 } |
127 |
134 |
|
135 void IrChannelModel::initWithCache() |
|
136 { |
|
137 if( NULL == iDB ) |
|
138 { |
|
139 iDB = new IRSearchResultDB(); |
|
140 } |
|
141 |
|
142 QList<IRQChannelItem*> *channelList = iDB->getCahcedChannelList(); |
|
143 |
|
144 if( NULL == channelList ) |
|
145 { |
|
146 //some error happens |
|
147 return; |
|
148 } |
|
149 |
|
150 clearAndDestroyItems(); |
|
151 clearAndDestroyLogos(); |
|
152 iChannelList = channelList; |
|
153 } |
|
154 |
|
155 void IrChannelModel::save2Cache() |
|
156 { |
|
157 if( NULL == iChannelList ) |
|
158 { |
|
159 return; |
|
160 } |
|
161 |
|
162 //ignore the return value |
|
163 iDB->cacheChannelList(iChannelList); |
|
164 } |
|
165 |
|
166 IRQChannelItem * IrChannelModel::getChannelItemByIndex(int aIndex) |
|
167 { |
|
168 if( aIndex < 0 || aIndex >= iChannelList->count() ) |
|
169 { |
|
170 return NULL; |
|
171 } |
|
172 |
|
173 return iChannelList->at(aIndex); |
|
174 } |
|
175 |
128 void IrChannelModel::clearAndDestroyLogos() |
176 void IrChannelModel::clearAndDestroyLogos() |
129 { |
177 { |
130 for (QMap<int, HbIcon*>::iterator it = iLogos.begin(); it != iLogos.end(); ++it) |
178 for (QMap<int, HbIcon*>::iterator it = iLogos.begin(); it != iLogos.end(); ++it) |
131 { |
179 { |
132 delete it.value(); |
180 delete it.value(); |