phonebookui/pbkcommonui/src/cntdetailorderinghelper.cpp
changeset 65 ae724a111993
parent 46 efe85016a067
equal deleted inserted replaced
59:a642906a277a 65:ae724a111993
   265     }
   265     }
   266     
   266     
   267     return orderedSupportedList;
   267     return orderedSupportedList;
   268 }
   268 }
   269 
   269 
       
   270 /**
       
   271 * Return ordered list of address details
       
   272 *
       
   273 * @param QContact&, contact
       
   274 * @return QList<QContactAddress>, ordered list of address details
       
   275 */   
       
   276 QList<QContactAddress> CntDetailOrderingHelper::getOrderedAddresses( const QContact& contact )
       
   277 {
       
   278     QMap<QString, int> orderMap;
       
   279     
       
   280     orderMap.insert("" , EAddress);
       
   281     orderMap.insert(QContactAddress::ContextHome , EAddressHome);
       
   282     orderMap.insert(QContactAddress::ContextWork , EAddressWork);
       
   283     
       
   284     QList<QContactAddress> completeList = contact.details<QContactAddress>();
       
   285     QList<QContactAddress> orderedSupportedList;
       
   286     
       
   287     foreach ( QContactAddress address, completeList )
       
   288     {
       
   289         QString context = address.contexts().isEmpty() ? QString() : address.contexts().first();
       
   290         
       
   291         if ( orderMap.keys().contains(context) )
       
   292         {
       
   293             int position = orderMap.value(context);
       
   294             bool added = false;
       
   295             
       
   296             for (int i = 0; i < orderedSupportedList.count(); i++)
       
   297             {
       
   298                 QString currentContext = orderedSupportedList.at(i).contexts().isEmpty() ? 
       
   299                         QString() : orderedSupportedList.at(i).contexts().first();
       
   300                 
       
   301                 int currentPosition = orderMap.value(currentContext);
       
   302                 
       
   303                 if (currentPosition > position)
       
   304                 {
       
   305                     orderedSupportedList.insert(i, address);
       
   306                     added = true;
       
   307                     break;
       
   308                 }
       
   309             }
       
   310             
       
   311             if (!added)
       
   312             {
       
   313                 orderedSupportedList.append(address);
       
   314             }
       
   315         }
       
   316     }
       
   317     
       
   318     return orderedSupportedList;
       
   319 }
       
   320 
   270 // EOF
   321 // EOF