emailuis/nmailui/src/nmmessagelistviewitem.cpp
changeset 43 99bcbff212ad
parent 40 2c62ef3caffd
child 44 c2d07d913565
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    37     mIcon2(NULL),
    37     mIcon2(NULL),
    38     mPrimarySize(0),
    38     mPrimarySize(0),
    39     mSecondarySize(0),
    39     mSecondarySize(0),
    40     mTinySize(0)    
    40     mTinySize(0)    
    41 {
    41 {
       
    42     NM_FUNCTION;
    42 }
    43 }
    43 
    44 
    44 /*!
    45 /*!
    45     Destruction.
    46     Destruction.
    46 */
    47 */
    47 NmMessageListViewItem::~NmMessageListViewItem()
    48 NmMessageListViewItem::~NmMessageListViewItem()
    48 {
    49 {
    49 
    50     NM_FUNCTION;
    50 }
    51 }
    51 
    52 
    52 /*!
    53 /*!
    53 */
    54 */
    54 HbTreeViewItem *NmMessageListViewItem::createItem()
    55 HbTreeViewItem *NmMessageListViewItem::createItem()
    55 {
    56 {
       
    57     NM_FUNCTION;
       
    58     
    56     return new NmMessageListViewItem(*this);
    59     return new NmMessageListViewItem(*this);
    57 }
    60 }
    58 
    61 
    59 /*!
    62 /*!
    60     boolean value indicating model index availability. Always true since
    63     boolean value indicating model index availability. Always true since
    61     this item prototype is used for both divider and message
    64     this item prototype is used for both divider and message
    62 */
    65 */
    63 bool NmMessageListViewItem::canSetModelIndex(const QModelIndex &index) const
    66 bool NmMessageListViewItem::canSetModelIndex(const QModelIndex &index) const
    64 {
    67 {
       
    68     NM_FUNCTION;
       
    69     
    65     Q_UNUSED(index);
    70     Q_UNUSED(index);
    66     // This item class can handle all items in message list
    71     // This item class can handle all items in message list
    67     return true;
    72     return true;
    68 }
    73 }
    69 
    74 
    71     update child items. List calls this function whenever item is needed
    76     update child items. List calls this function whenever item is needed
    72     to be updated.
    77     to be updated.
    73 */
    78 */
    74 void NmMessageListViewItem::updateChildItems()
    79 void NmMessageListViewItem::updateChildItems()
    75 {
    80 {
       
    81     NM_FUNCTION;
       
    82     
    76     // Get model pointer
    83     // Get model pointer
    77     NmMessageListModelItem *msgModelItem = modelIndex().data(
    84     NmMessageListModelItem *msgModelItem = modelIndex().data(
    78             Qt::DisplayRole).value<NmMessageListModelItem*>();
    85             Qt::DisplayRole).value<NmMessageListModelItem*>();
    79     // Check whether item is message item or title divider
    86     // Check whether item is message item or title divider
    80     // and set the layout accordingly, dividers not currently used
    87     // and set the layout accordingly, dividers not currently used
    95     Set item layout.
   102     Set item layout.
    96     Function does not take ownership of model or model item
   103     Function does not take ownership of model or model item
    97 */
   104 */
    98 void NmMessageListViewItem::createMessageItemLayout()
   105 void NmMessageListViewItem::createMessageItemLayout()
    99 { 
   106 { 
       
   107     NM_FUNCTION;
       
   108     
   100     getFontSizes();
   109     getFontSizes();
   101     // Create sender label and set name from widgetml
   110     // Create sender label and set name from widgetml
   102     if (!mSender){
   111     if (!mSender){
   103         mSender = new HbTextItem(this);
   112         mSender = new HbTextItem(this);
   104         HbStyle::setItemName(mSender, "sender");
   113         HbStyle::setItemName(mSender, "sender");
   144     Function does not take ownership of model or model item
   153     Function does not take ownership of model or model item
   145 */
   154 */
   146 void NmMessageListViewItem::setContentsToMessageItem(const NmMessageEnvelope &envelope, 
   155 void NmMessageListViewItem::setContentsToMessageItem(const NmMessageEnvelope &envelope, 
   147                                                      bool dividersActive)
   156                                                      bool dividersActive)
   148 {
   157 {
       
   158     NM_FUNCTION;
       
   159     
   149     // member variables are created in previous function
   160     // member variables are created in previous function
   150     // sender
   161     // sender
   151     mSender->setText(senderFieldText(envelope));
   162     mSender->setText(senderFieldText(envelope));
   152     // time
   163     // time
   153     HbExtendedLocale locale = HbExtendedLocale::system();
   164     HbExtendedLocale locale = HbExtendedLocale::system();
   229 void NmMessageListViewItem::paint(
   240 void NmMessageListViewItem::paint(
   230     QPainter *painter,
   241     QPainter *painter,
   231     const QStyleOptionGraphicsItem *option,
   242     const QStyleOptionGraphicsItem *option,
   232     QWidget *widget)
   243     QWidget *widget)
   233 {
   244 {
       
   245     NM_FUNCTION;
       
   246     
   234     Q_UNUSED(option);
   247     Q_UNUSED(option);
   235     Q_UNUSED(widget);
   248     Q_UNUSED(widget);
   236     Q_UNUSED(painter);
   249     Q_UNUSED(painter);
   237 }
   250 }
   238 
   251 
   239 /*!
   252 /*!
   240     setFontsUnread
   253     setFontsUnread
   241 */
   254 */
   242 void  NmMessageListViewItem::setFontsUnread()
   255 void  NmMessageListViewItem::setFontsUnread()
   243 {    
   256 {    
       
   257     NM_FUNCTION;
       
   258     
   244     static QColor colorRole = HbColorScheme::color("qtc_list_item_title_normal");
   259     static QColor colorRole = HbColorScheme::color("qtc_list_item_title_normal");
   245     HbFontSpec spekki(HbFontSpec::Primary);
   260     HbFontSpec spekki(HbFontSpec::Primary);
   246     setFonts(colorRole, spekki);
   261     setFonts(colorRole, spekki);
   247 }
   262 }
   248 
   263 
   249 /*!
   264 /*!
   250     setFontsRead
   265     setFontsRead
   251 */
   266 */
   252 void  NmMessageListViewItem::setFontsRead()
   267 void  NmMessageListViewItem::setFontsRead()
   253 {
   268 {
       
   269     NM_FUNCTION;
       
   270     
   254     static QColor colorRole = HbColorScheme::color("qtc_list_item_content_normal");
   271     static QColor colorRole = HbColorScheme::color("qtc_list_item_content_normal");
   255     HbFontSpec spekki(HbFontSpec::Secondary);
   272     HbFontSpec spekki(HbFontSpec::Secondary);
   256     setFonts(colorRole, spekki);
   273     setFonts(colorRole, spekki);
   257 }
   274 }
   258 
   275 
   259 /*!
   276 /*!
   260     getFontSizes.
   277     getFontSizes.
   261 */
   278 */
   262 void  NmMessageListViewItem::getFontSizes()
   279 void  NmMessageListViewItem::getFontSizes()
   263 {
   280 {
       
   281     NM_FUNCTION;
       
   282     
   264     // Get font sizes from style  
   283     // Get font sizes from style  
   265     qreal currentSize;
   284     qreal currentSize;
   266     HbStyle mystyle;
   285     HbStyle mystyle;
   267     bool found = mystyle.parameter(QString("hb-param-text-height-primary"), currentSize );
   286     bool found = mystyle.parameter(QString("hb-param-text-height-primary"), currentSize );
   268     if (found) {
   287     if (found) {
   282     setFonts.
   301     setFonts.
   283 */
   302 */
   284 void  NmMessageListViewItem::setFonts(const QColor &colorRole, 
   303 void  NmMessageListViewItem::setFonts(const QColor &colorRole, 
   285         HbFontSpec &spekki)
   304         HbFontSpec &spekki)
   286 {
   305 {
       
   306     NM_FUNCTION;
       
   307     
   287     // Change sizes explicitly since css is overwritten in polish now.    
   308     // Change sizes explicitly since css is overwritten in polish now.    
   288     if (mSender && mSubject && mTime) {
   309     if (mSender && mSubject && mTime) {
   289         
   310         
   290         if (mPrimarySize) {
   311         if (mPrimarySize) {
   291             spekki.setTextHeight(mPrimarySize);
   312             spekki.setTextHeight(mPrimarySize);
   311     senderFieldText. Function returns sender field text from
   332     senderFieldText. Function returns sender field text from
   312     envelope based on currently used function
   333     envelope based on currently used function
   313 */
   334 */
   314 QString NmMessageListViewItem::senderFieldText(const NmMessageEnvelope &envelope)
   335 QString NmMessageListViewItem::senderFieldText(const NmMessageEnvelope &envelope)
   315 {
   336 {
       
   337     NM_FUNCTION;
       
   338     
   316     QString ret;  
   339     QString ret;  
   317     QVariant folderType = modelIndex().data(
   340     QVariant folderType = modelIndex().data(
   318             NmFolderTypeRole).value<QVariant>();
   341             NmFolderTypeRole).value<QVariant>();
   319     switch (folderType.toInt()) {
   342     switch (folderType.toInt()) {
   320         // Outbox, drafts and sent folder, sender name is 
   343         // Outbox, drafts and sent folder, sender name is