qtinternetradio/ui/src/irhistorymodel.cpp
changeset 3 ee64f059b8e1
parent 0 09774dfdd46b
child 17 38bbf2dcd608
equal deleted inserted replaced
2:2e1adbfc62af 3:ee64f059b8e1
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <hbicon.h>
    18 #include <hbicon.h>
    19 #include <QBrush>
       
    20 
    19 
    21 #include "irqsonghistoryinfo.h"
    20 #include "irqsonghistoryinfo.h"
    22 #include "irqsonghistoryengine.h"
    21 #include "irqsonghistoryengine.h"
    23 #include "irhistorymodel.h"
    22 #include "irhistorymodel.h"
    24 #include "iruidefines.h"
       
    25 
    23 
    26 IRHistoryModel::IRHistoryModel(QObject *aParent) : QAbstractListModel(aParent)
    24 IRHistoryModel::IRHistoryModel(QObject *aParent) : QAbstractListModel(aParent)
    27 {
    25 {
    28     iStationLogo = new HbIcon(":/stationlist/icon_stationdefault.png");
    26     iStationLogo = new HbIcon("qtg_large_internet_radio");
    29 
    27 
    30     iHistoryEngine = IRQSongHistoryEngine::openInstance();
    28     iHistoryEngine = IRQSongHistoryEngine::openInstance();
    31     getAllList();
    29     getAllList();
    32 }
    30 }
    33 
    31 
    82     if (aRole == Qt::DisplayRole)
    80     if (aRole == Qt::DisplayRole)
    83     {
    81     {
    84         QVariantList list;
    82         QVariantList list;
    85         
    83         
    86         int row = aIndex.row();
    84         int row = aIndex.row();
    87         QString primaryText = QString::number(row+1) + ". " + iHistoryList.at(row)->getChannelName();
    85         QString primaryText = iHistoryList.at(row)->getChannelName();
    88         list.append(primaryText);
    86         list.append(primaryText);
    89         // fix bug #9888,if left descriptions as blank, only one line appears
    87         // fix bug #9888,if left descriptions as blank, only one line appears
    90         QString tempDes = iHistoryList.at(row)->getChannelDesc();
    88         QString tempDes = iHistoryList.at(row)->getChannelDesc();
    91         if (0 == tempDes.length())
    89         if (0 == tempDes.length())
    92         {
    90         {
   109         {
   107         {
   110             list.append(*iStationLogo);
   108             list.append(*iStationLogo);
   111         }
   109         }
   112         
   110         
   113         return list;
   111         return list;
   114     }
       
   115     else if (aRole == Qt::BackgroundRole)
       
   116     {
       
   117         if (aIndex.row() % 2 == 0)
       
   118         {
       
   119             return QBrush(KListEvenRowColor);
       
   120         }
       
   121         else
       
   122         {
       
   123             return QBrush(KListOddRowColor);
       
   124         }
       
   125     }
   112     }
   126 
   113 
   127     return QVariant();
   114     return QVariant();
   128 }
   115 }
   129 
   116