--- a/qtinternetradio/ui/src/irchannelmodel.cpp Thu May 27 12:46:34 2010 +0300
+++ b/qtinternetradio/ui/src/irchannelmodel.cpp Fri Jun 11 13:30:40 2010 +0300
@@ -19,9 +19,10 @@
#include "irchannelmodel.h"
#include "irqisdsdatastructure.h"
+#include "irsearchresultdb.h"
IrChannelModel::IrChannelModel(QObject *aParent): QAbstractListModel(aParent)
- , iChannelList(NULL)
+ , iChannelList(NULL),iDB(NULL)
{
iStationLogo = new HbIcon("qtg_large_internet_radio");
}
@@ -34,6 +35,12 @@
iStationLogo = NULL;
clearAndDestroyLogos();
+
+ if( iDB )
+ {
+ delete iDB;
+ iDB = NULL;
+ }
}
int IrChannelModel::rowCount(const QModelIndex &aParent) const
@@ -125,6 +132,47 @@
emit dataAvailable();
}
+void IrChannelModel::initWithCache()
+{
+ if( NULL == iDB )
+ {
+ iDB = new IRSearchResultDB();
+ }
+
+ QList<IRQChannelItem*> *channelList = iDB->getCahcedChannelList();
+
+ if( NULL == channelList )
+ {
+ //some error happens
+ return;
+ }
+
+ clearAndDestroyItems();
+ clearAndDestroyLogos();
+ iChannelList = channelList;
+}
+
+void IrChannelModel::save2Cache()
+{
+ if( NULL == iChannelList )
+ {
+ return;
+ }
+
+ //ignore the return value
+ iDB->cacheChannelList(iChannelList);
+}
+
+IRQChannelItem * IrChannelModel::getChannelItemByIndex(int aIndex)
+{
+ if( aIndex < 0 || aIndex >= iChannelList->count() )
+ {
+ return NULL;
+ }
+
+ return iChannelList->at(aIndex);
+}
+
void IrChannelModel::clearAndDestroyLogos()
{
for (QMap<int, HbIcon*>::iterator it = iLogos.begin(); it != iLogos.end(); ++it)