locationpickerservice/src/hgwidgetdatamodel.cpp
changeset 31 8db05346071b
parent 30 96df3ab41000
child 35 59575560d1e6
equal deleted inserted replaced
30:96df3ab41000 31:8db05346071b
    74 // ----------------------------------------------------------------------------
    74 // ----------------------------------------------------------------------------
    75 // HgWidgetDataModel::data()
    75 // HgWidgetDataModel::data()
    76 // ----------------------------------------------------------------------------
    76 // ----------------------------------------------------------------------------
    77 QVariant HgWidgetDataModel::data(const QModelIndex &aIndex, int aRole) const
    77 QVariant HgWidgetDataModel::data(const QModelIndex &aIndex, int aRole) const
    78 {   
    78 {   
    79     Q_ASSERT(aIndex.row()>=0);
       
    80     int row= aIndex.row();
    79     int row= aIndex.row();
    81     int col = aIndex.column();
    80     int col = aIndex.column();
    82     //get proxy model index
    81     //get proxy model index
    83     QModelIndex proxyModelIndex = mProxyModel->index(row,col);
    82     QModelIndex proxyModelIndex = mProxyModel->index(row,col);
    84     QVariant returnValue = QVariant();
    83     QVariant returnValue = QVariant();
   100         }
    99         }
   101         break;
   100         break;
   102         case Qt::DisplayRole:
   101         case Qt::DisplayRole:
   103         {
   102         {
   104             QStringList displayText;
   103             QStringList displayText;
   105             QString adressDetail = mProxyModel->data(proxyModelIndex,Qt::DisplayRole).toString();
   104             QStringList adressDetail = mProxyModel->data(proxyModelIndex,Qt::DisplayRole).toStringList();
       
   105             QString displayString = adressDetail[0]+KSeparator+KSpace+adressDetail[1];
   106             QString text("");
   106             QString text("");
   107             displayText <<adressDetail<<text;
   107             displayText <<displayString<<text;
   108             returnValue = displayText;
   108             returnValue = displayText;
   109             break;
   109             break;
   110         }
   110         }
   111         case Qt::DecorationRole:
   111         case Qt::DecorationRole:
   112         {
   112         {
   113             //get icon name from data model
   113             //get icon name from data model
   114             QString iconName =  mProxyModel->data(proxyModelIndex,Qt::DecorationRole).toString();
   114             QString iconName =  mProxyModel->data(proxyModelIndex,Qt::UserRole+1).toString();
   115             if (iconName.isNull()) 
   115             if (iconName.isEmpty()) 
   116             {
   116             {
   117                 returnValue = mDefaultImage;
   117                 returnValue = mDefaultImage;
   118             }
   118             }
   119             else 
   119             else 
   120             {   
   120             {   
   121                 QString adressType =  mProxyModel->data(proxyModelIndex,Qt::UserRole+1).toString();
   121                 QString adressType =  mProxyModel->data(proxyModelIndex,Qt::UserRole+2).toString();
   122                 QPixmap mapPixmap(iconName);
   122                 QPixmap mapPixmap(iconName);
   123                 int mapWidth = mapPixmap.width();
   123                 int mapWidth = mapPixmap.width();
   124                 int mapHeight = mapPixmap.height();
   124                 int mapHeight = mapPixmap.height();
   125                 QBrush brush(Qt::black,Qt::SolidPattern);
   125                 QBrush brush(Qt::black,Qt::SolidPattern);
   126                 QPainter painter;
   126                 QPainter painter;