emailuis/nmailui/src/nmutilities.cpp
changeset 68 83cc6bae1de8
parent 62 a8c646b56683
child 74 6c59112cfd31
equal deleted inserted replaced
67:459da34cdb45 68:83cc6bae1de8
   248     qreal sizeMb = (qreal)sizeInBytes / (qreal)NmMegabyte;
   248     qreal sizeMb = (qreal)sizeInBytes / (qreal)NmMegabyte;
   249     if (sizeMb < NmMinAttachmentSize) {
   249     if (sizeMb < NmMinAttachmentSize) {
   250         // NmMinAttachmentSize (0.1Mb) is the minimum size shown for attachment
   250         // NmMinAttachmentSize (0.1Mb) is the minimum size shown for attachment
   251         sizeMb = NmMinAttachmentSize;
   251         sizeMb = NmMinAttachmentSize;
   252     }   
   252     }   
   253     return QString().sprintf("(%.1f Mb)", sizeMb); // Use loc string when available
   253     return HbStringUtil::convertDigits(hbTrId("txt_mail_list_l1_mb").arg(sizeMb, 0, 'f', 1));
   254 }
   254 }
   255 
   255 
   256 /*!
   256 /*!
   257     Displays a note with Yes/No buttons. Note has no timeout, i.e. it has to be dismissed manually.
   257     Displays a note with Yes/No buttons. Note has no timeout, i.e. it has to be dismissed manually.
   258     Returns pointer to dialog so that caller can take ownership and handle deletion.
   258     Returns pointer to dialog so that caller can take ownership and handle deletion.
   372         }
   372         }
   373     }
   373     }
   374     ret+="<br></body></html>";
   374     ret+="<br></body></html>";
   375     return ret;
   375     return ret;
   376 }
   376 }
       
   377 
       
   378 /*
       
   379  * Function creates NmAddress object from a string, which can
       
   380  * be just an email address or display name and email address in format
       
   381  * Firstname Lastname <firstname.lastname@example.com>.
       
   382  * \param str email address string
       
   383  * \return NmAddress with address and possible display name 
       
   384  */
       
   385 NmAddress *NmUtilities::qstringToNmAddress(QString str)
       
   386 {
       
   387     QRegExp NmEmailDisplayNamePattern("<"+NmEmailAddressPattern.pattern()+">$");
       
   388     NmAddress *nmAddress = NULL;
       
   389     str = str.simplified();
       
   390     if (str.contains(NmEmailDisplayNamePattern)) {
       
   391         QString original = str;
       
   392         QString displayName = str.remove(NmEmailDisplayNamePattern).trimmed();
       
   393         QRegExp NmEmailGreaterThenLessThen(">|<");
       
   394         QString address = original.remove(displayName).remove(NmEmailGreaterThenLessThen).trimmed();
       
   395         nmAddress = new NmAddress(displayName,address);
       
   396     }
       
   397     else {
       
   398         nmAddress = new NmAddress(str);
       
   399     }
       
   400     return nmAddress;
       
   401 }