emailuis/nmailui/src/nmmessagelistviewitem.cpp
author hgs
Fri, 03 Sep 2010 14:07:42 +0300
changeset 66 084b5b1f02a7
parent 62 a8c646b56683
child 68 83cc6bae1de8
permissions -rw-r--r--
201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
57
hgs
parents: 56
diff changeset
     2
 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents: 56
diff changeset
     3
 * All rights reserved.
hgs
parents: 56
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents: 56
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents: 56
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents: 56
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents: 56
diff changeset
     8
 *
hgs
parents: 56
diff changeset
     9
 * Initial Contributors:
hgs
parents: 56
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents: 56
diff changeset
    11
 *
hgs
parents: 56
diff changeset
    12
 * Contributors:
hgs
parents: 56
diff changeset
    13
 *
hgs
parents: 56
diff changeset
    14
 * Description:
hgs
parents: 56
diff changeset
    15
 *
hgs
parents: 56
diff changeset
    16
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include "nmuiheaders.h"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
    \class NmMessageListViewItem
57
hgs
parents: 56
diff changeset
    22
    \brief List view item for message list view.
hgs
parents: 56
diff changeset
    23
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
40
hgs
parents: 23
diff changeset
    25
static const int NmFolderTypeRole = Qt::UserRole+1; 
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
/*!
57
hgs
parents: 56
diff changeset
    28
    Constructor.
hgs
parents: 56
diff changeset
    29
 */
hgs
parents: 56
diff changeset
    30
NmMessageListViewItem::NmMessageListViewItem(QGraphicsItem *parent)
hgs
parents: 56
diff changeset
    31
: HbTreeViewItem(parent),
hgs
parents: 56
diff changeset
    32
  mSender(NULL),
hgs
parents: 56
diff changeset
    33
  mSubject(NULL),
hgs
parents: 56
diff changeset
    34
  mTime(NULL),
hgs
parents: 56
diff changeset
    35
  mDividerTitle(NULL),
hgs
parents: 56
diff changeset
    36
  mNewMsgIcon(NULL),
hgs
parents: 56
diff changeset
    37
  mIcon1(NULL),
hgs
parents: 56
diff changeset
    38
  mIcon2(NULL),
hgs
parents: 56
diff changeset
    39
  mPrimarySize(0),
hgs
parents: 56
diff changeset
    40
  mSecondarySize(0)   
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
{
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
/*!
57
hgs
parents: 56
diff changeset
    45
    Destructor.
hgs
parents: 56
diff changeset
    46
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
NmMessageListViewItem::~NmMessageListViewItem()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
{
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
/*!
57
hgs
parents: 56
diff changeset
    52
    Create item.
hgs
parents: 56
diff changeset
    53
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
HbTreeViewItem *NmMessageListViewItem::createItem()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
{
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
    return new NmMessageListViewItem(*this);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
/*!
57
hgs
parents: 56
diff changeset
    60
    Boolean value indicating model index availability. Always true since
hgs
parents: 56
diff changeset
    61
    this item prototype is used for both divider and message.
hgs
parents: 56
diff changeset
    62
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
bool NmMessageListViewItem::canSetModelIndex(const QModelIndex &index) const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
{
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    Q_UNUSED(index);
57
hgs
parents: 56
diff changeset
    66
    // This item class can handle all items in message list.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    return true;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
/*!
57
hgs
parents: 56
diff changeset
    71
    Update child items. List calls this function whenever item is needed
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
    to be updated.
57
hgs
parents: 56
diff changeset
    73
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
void NmMessageListViewItem::updateChildItems()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
{
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
    // Get model pointer
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
    NmMessageListModelItem *msgModelItem = modelIndex().data(
57
hgs
parents: 56
diff changeset
    78
        Qt::DisplayRole).value<NmMessageListModelItem*>();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    // Check whether item is message item or title divider
57
hgs
parents: 56
diff changeset
    80
    // and set the layout accordingly. Dividers are not currently used.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    if (msgModelItem && msgModelItem->itemType() ==
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
        NmMessageListModelItem::NmMessageItemMessage){
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
        NmMessageListModel *model = static_cast<NmMessageListModel*>(msgModelItem->model());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
        if (model){
57
hgs
parents: 56
diff changeset
    85
            // First set item layout.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
            createMessageItemLayout();
57
hgs
parents: 56
diff changeset
    87
            // Set content data to item after layout is created.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
            setContentsToMessageItem(msgModelItem->envelope(), model->dividersActive());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    HbTreeViewItem::updateChildItems();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    Set item layout.
57
hgs
parents: 56
diff changeset
    96
    Function does not take ownership of model or model item.
hgs
parents: 56
diff changeset
    97
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
void NmMessageListViewItem::createMessageItemLayout()
57
hgs
parents: 56
diff changeset
    99
{
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    getFontSizes();
57
hgs
parents: 56
diff changeset
   101
    // Create sender label and set name from widgetml.
hgs
parents: 56
diff changeset
   102
    if (!mSender) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
        mSender = new HbTextItem(this);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
        HbStyle::setItemName(mSender, "sender");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
        mSender->setObjectName("ListViewItemMessageSender");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    }
57
hgs
parents: 56
diff changeset
   107
    // Create time label and set name from widgetml.
hgs
parents: 56
diff changeset
   108
    if (!mTime) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
        mTime = new HbTextItem(this);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
        HbStyle::setItemName(mTime, "time");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
        mTime->setObjectName("ListViewItemMessageTime");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    }
57
hgs
parents: 56
diff changeset
   113
    // Create subject label and set name from widgetml.
hgs
parents: 56
diff changeset
   114
    if (!mSubject) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
        mSubject = new HbTextItem(this);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
        HbStyle::setItemName(mSubject, "subject");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
        mSubject->setObjectName("ListViewItemMessageSubject");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
    }
57
hgs
parents: 56
diff changeset
   119
    // Set new message icon.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    if (!mNewMsgIcon) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
        mNewMsgIcon = new HbFrameItem(this);
57
hgs
parents: 56
diff changeset
   122
    }
hgs
parents: 56
diff changeset
   123
    // Create priority icon and set name from widgetml.
hgs
parents: 56
diff changeset
   124
    if (!mIcon1) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
        mIcon1 = new HbIconItem(this);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
        HbStyle::setItemName(mIcon1, "icon1");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
    }
57
hgs
parents: 56
diff changeset
   128
    // Create attachment icon and set name from widgetml.
hgs
parents: 56
diff changeset
   129
    if (!mIcon2) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
        mIcon2 = new HbIconItem(this);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
        HbStyle::setItemName(mIcon2, "icon2");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    setObjectName("ListViewItemMessage");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
/*!
62
hgs
parents: 57
diff changeset
   137
    Sets the item text label contents, icons, etc. The method does not take
hgs
parents: 57
diff changeset
   138
    ownership of model or model item.
hgs
parents: 57
diff changeset
   139
hgs
parents: 57
diff changeset
   140
    \param envelope The message envelope.
hgs
parents: 57
diff changeset
   141
    \param dividersActive 
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
void NmMessageListViewItem::setContentsToMessageItem(const NmMessageEnvelope &envelope, 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
                                                     bool dividersActive)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
{
57
hgs
parents: 56
diff changeset
   146
    // Member variables are created in previous function.
hgs
parents: 56
diff changeset
   147
    // Sender.
40
hgs
parents: 23
diff changeset
   148
    mSender->setText(senderFieldText(envelope));
62
hgs
parents: 57
diff changeset
   149
57
hgs
parents: 56
diff changeset
   150
    // Time.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
    HbExtendedLocale locale = HbExtendedLocale::system();
44
hgs
parents: 43
diff changeset
   152
    QDateTime localTime = envelope.sentTime().addSecs(locale.universalTimeOffset());
hgs
parents: 43
diff changeset
   153
    QDate sentLocalDate = localTime.date();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    QDate currentdate = QDate::currentDate();
62
hgs
parents: 57
diff changeset
   155
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    if (dividersActive || sentLocalDate == currentdate) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
        QString shortTimeSpec = r_qtn_time_usual;
44
hgs
parents: 43
diff changeset
   158
        QTime time = localTime.time();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
        mTime->setText(locale.format(time, shortTimeSpec));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    } else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
        QString shortDateSpec = r_qtn_date_without_year;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
        mTime->setText(locale.format(sentLocalDate, shortDateSpec));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
    }
62
hgs
parents: 57
diff changeset
   164
57
hgs
parents: 56
diff changeset
   165
    // Subject.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    QString subjectText = envelope.subject();
62
hgs
parents: 57
diff changeset
   167
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    if (subjectText.length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
        mSubject->setText(subjectText);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
    } else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
        mSubject->setText(hbTrId("txt_mail_dblist_val_no_subject"));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
    }
62
hgs
parents: 57
diff changeset
   173
57
hgs
parents: 56
diff changeset
   174
    // Priority.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    bool priorityIs(false);
62
hgs
parents: 57
diff changeset
   176
hgs
parents: 57
diff changeset
   177
    mIcon1->setIcon(HbIcon());
hgs
parents: 57
diff changeset
   178
    mIcon1->setObjectName(QString());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    mIcon1->hide();
62
hgs
parents: 57
diff changeset
   180
    mIcon2->setIcon(HbIcon());
hgs
parents: 57
diff changeset
   181
    mIcon2->setObjectName(QString());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
    mIcon2->hide();
62
hgs
parents: 57
diff changeset
   183
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
    switch (envelope.priority()) {
62
hgs
parents: 57
diff changeset
   185
        case NmMessagePriorityLow: {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
            priorityIs = true;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
            mIcon1->setObjectName("ListViewItemMessageIconPriorityLow");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
            mIcon1->setIcon(NmIcons::getIcon(NmIcons::NmIconPriorityLow));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
            mIcon1->show();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
            break;
62
hgs
parents: 57
diff changeset
   191
        }
hgs
parents: 57
diff changeset
   192
        case NmMessagePriorityHigh: {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
            priorityIs = true;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
            mIcon1->setObjectName("ListViewItemMessageIconPriorityHigh");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
            mIcon1->setIcon(NmIcons::getIcon(NmIcons::NmIconPriorityHigh));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
            mIcon1->show();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
            break;
62
hgs
parents: 57
diff changeset
   198
        }
hgs
parents: 57
diff changeset
   199
        case NmMessagePriorityNormal: {
hgs
parents: 57
diff changeset
   200
            break;
hgs
parents: 57
diff changeset
   201
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
        default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    }
57
hgs
parents: 56
diff changeset
   205
    // Attachments.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    HbIconItem *attaIcon = (priorityIs ? mIcon2 : mIcon1);
62
hgs
parents: 57
diff changeset
   207
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
    if (envelope.hasAttachments()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
        HbIcon &icon = NmIcons::getIcon(NmIcons::NmIconAttachment);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
        attaIcon->setIcon(icon);
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   211
        attaIcon->setObjectName("ListViewItemMessageIconAttachment");
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
        attaIcon->show();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
    }
62
hgs
parents: 57
diff changeset
   214
    else {
hgs
parents: 57
diff changeset
   215
        attaIcon->setIcon(HbIcon());
hgs
parents: 57
diff changeset
   216
        attaIcon->setObjectName(QString());
hgs
parents: 57
diff changeset
   217
    }
hgs
parents: 57
diff changeset
   218
57
hgs
parents: 56
diff changeset
   219
    // Message read status.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
    bool msgReadStatus(envelope.isRead());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
    HbFrameDrawer *drawer(NULL);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    HbStyle::setItemName(mNewMsgIcon, "msgicon");
62
hgs
parents: 57
diff changeset
   223
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    if (!msgReadStatus) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
        setFontsUnread();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
        mNewMsgIcon->setObjectName("ListViewItemMessageIconUnread");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
        drawer = new HbFrameDrawer("qtg_fr_list_new_item",
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
                HbFrameDrawer::ThreePiecesVertical);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
        drawer->setFillWholeRect(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
        // Set drawer. Takes ownership of the drawer and deletes previous drawer.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
        mNewMsgIcon->setFrameDrawer(drawer);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   232
        mNewMsgIcon->show();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    } else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
        setFontsRead();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
        mNewMsgIcon->setObjectName("ListViewItemMessageIconRead");
57
hgs
parents: 56
diff changeset
   236
        drawer = new HbFrameDrawer(); // Create empty drawer.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
        drawer->setFillWholeRect(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
        // Set drawer. Takes ownership of the drawer and deletes previous drawer.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
        mNewMsgIcon->setFrameDrawer(drawer);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   240
        mNewMsgIcon->hide();        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
/*!
57
hgs
parents: 56
diff changeset
   245
    Set fonts unread.
hgs
parents: 56
diff changeset
   246
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
void  NmMessageListViewItem::setFontsUnread()
57
hgs
parents: 56
diff changeset
   248
{
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   249
    static QColor colorRole = HbColorScheme::color("qtc_list_item_title_normal");
47
hgs
parents: 44
diff changeset
   250
    HbFontSpec fontSpec(HbFontSpec::Primary);
hgs
parents: 44
diff changeset
   251
    setFonts(colorRole, fontSpec);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
40
hgs
parents: 23
diff changeset
   254
/*!
57
hgs
parents: 56
diff changeset
   255
    Set fonts read.
hgs
parents: 56
diff changeset
   256
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
void  NmMessageListViewItem::setFontsRead()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
{
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   259
    static QColor colorRole = HbColorScheme::color("qtc_list_item_content_normal");
47
hgs
parents: 44
diff changeset
   260
    HbFontSpec fontSpec(HbFontSpec::Secondary);
hgs
parents: 44
diff changeset
   261
    setFonts(colorRole, fontSpec);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
40
hgs
parents: 23
diff changeset
   264
/*!
57
hgs
parents: 56
diff changeset
   265
    Get font sizes.
hgs
parents: 56
diff changeset
   266
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
void  NmMessageListViewItem::getFontSizes()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
{
57
hgs
parents: 56
diff changeset
   269
    // Get font sizes from style.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
    qreal currentSize;
47
hgs
parents: 44
diff changeset
   271
    bool found = style()->parameter(QString("hb-param-text-height-primary"), currentSize );
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    if (found) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
        mPrimarySize = currentSize;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    }      
47
hgs
parents: 44
diff changeset
   275
    found = style()->parameter(QString("hb-param-text-height-secondary"), currentSize );
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    if (found) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
        mSecondarySize = currentSize;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
    }        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
40
hgs
parents: 23
diff changeset
   281
/*!
57
hgs
parents: 56
diff changeset
   282
    Set fonts.
hgs
parents: 56
diff changeset
   283
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
void  NmMessageListViewItem::setFonts(const QColor &colorRole, 
47
hgs
parents: 44
diff changeset
   285
        HbFontSpec &fontSpec)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
{
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
    // Change sizes explicitly since css is overwritten in polish now.    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    if (mSender && mSubject && mTime) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
        if (mPrimarySize) {
47
hgs
parents: 44
diff changeset
   290
            fontSpec.setTextHeight(mPrimarySize);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
        }      
47
hgs
parents: 44
diff changeset
   292
        mSender->setFontSpec(fontSpec);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
        mSender->setTextColor(colorRole);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
        if (mSecondarySize) {
47
hgs
parents: 44
diff changeset
   295
            fontSpec.setTextHeight(mSecondarySize);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
        }        
47
hgs
parents: 44
diff changeset
   297
        mSubject->setFontSpec(fontSpec);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
        mSubject->setTextColor(colorRole);
47
hgs
parents: 44
diff changeset
   299
        mTime->setFontSpec(fontSpec);        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
        mTime->setTextColor(colorRole);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
40
hgs
parents: 23
diff changeset
   304
/*!
57
hgs
parents: 56
diff changeset
   305
    Get sender field text. Function returns sender field text from
hgs
parents: 56
diff changeset
   306
    envelope based on currently used function.
hgs
parents: 56
diff changeset
   307
 */
40
hgs
parents: 23
diff changeset
   308
QString NmMessageListViewItem::senderFieldText(const NmMessageEnvelope &envelope)
hgs
parents: 23
diff changeset
   309
{
hgs
parents: 23
diff changeset
   310
    QString ret;  
hgs
parents: 23
diff changeset
   311
    QVariant folderType = modelIndex().data(
hgs
parents: 23
diff changeset
   312
            NmFolderTypeRole).value<QVariant>();
hgs
parents: 23
diff changeset
   313
    switch (folderType.toInt()) {
hgs
parents: 23
diff changeset
   314
        // Outbox, drafts and sent folder, sender name is 
57
hgs
parents: 56
diff changeset
   315
        // replaced with first recipient from to/cc list.
40
hgs
parents: 23
diff changeset
   316
        case NmFolderOutbox:
hgs
parents: 23
diff changeset
   317
        case NmFolderDrafts:
hgs
parents: 23
diff changeset
   318
        case NmFolderSent:
hgs
parents: 23
diff changeset
   319
        {
hgs
parents: 23
diff changeset
   320
            QList<NmAddress>& toRecipients = envelope.toRecipients();
hgs
parents: 23
diff changeset
   321
            QList<NmAddress>& ccRecipients = envelope.ccRecipients();
hgs
parents: 23
diff changeset
   322
            NmAddress addressToUse;
hgs
parents: 23
diff changeset
   323
            bool foundAddress(false);
hgs
parents: 23
diff changeset
   324
            if (toRecipients.count()){
hgs
parents: 23
diff changeset
   325
                addressToUse=toRecipients[0];
hgs
parents: 23
diff changeset
   326
                foundAddress=true;
hgs
parents: 23
diff changeset
   327
            }
hgs
parents: 23
diff changeset
   328
            else if (ccRecipients.count()) {
hgs
parents: 23
diff changeset
   329
                addressToUse=ccRecipients[0]; 
hgs
parents: 23
diff changeset
   330
                foundAddress=true;         
hgs
parents: 23
diff changeset
   331
            }
hgs
parents: 23
diff changeset
   332
            if (foundAddress){
hgs
parents: 23
diff changeset
   333
                QString displayName = addressToUse.displayName();
hgs
parents: 23
diff changeset
   334
                if (displayName.length()) {
hgs
parents: 23
diff changeset
   335
                    ret += NmUtilities::cleanupDisplayName(displayName);
hgs
parents: 23
diff changeset
   336
                } 
hgs
parents: 23
diff changeset
   337
                else {
hgs
parents: 23
diff changeset
   338
                    ret += addressToUse.address();                    
hgs
parents: 23
diff changeset
   339
                }               
hgs
parents: 23
diff changeset
   340
            }
hgs
parents: 23
diff changeset
   341
        }
hgs
parents: 23
diff changeset
   342
        break;    
57
hgs
parents: 56
diff changeset
   343
        // All other folders will show sender display name.
40
hgs
parents: 23
diff changeset
   344
        default: 
hgs
parents: 23
diff changeset
   345
        {
hgs
parents: 23
diff changeset
   346
            QString displayName = envelope.sender().displayName();
hgs
parents: 23
diff changeset
   347
            if (displayName.length()) {
hgs
parents: 23
diff changeset
   348
                ret += NmUtilities::cleanupDisplayName(displayName);
hgs
parents: 23
diff changeset
   349
            } 
hgs
parents: 23
diff changeset
   350
            else {
hgs
parents: 23
diff changeset
   351
                ret += envelope.sender().address();                    
hgs
parents: 23
diff changeset
   352
            }
hgs
parents: 23
diff changeset
   353
        }
hgs
parents: 23
diff changeset
   354
        break;
hgs
parents: 23
diff changeset
   355
    }
hgs
parents: 23
diff changeset
   356
    return ret;
hgs
parents: 23
diff changeset
   357
}
66
hgs
parents: 62
diff changeset
   358
hgs
parents: 62
diff changeset
   359
/*!
hgs
parents: 62
diff changeset
   360
    Handle font color changes in the case of theme change
hgs
parents: 62
diff changeset
   361
 */ 
hgs
parents: 62
diff changeset
   362
bool NmMessageListViewItem::event(QEvent *event)
hgs
parents: 62
diff changeset
   363
{
hgs
parents: 62
diff changeset
   364
    bool ret = HbTreeViewItem::event(event);    
hgs
parents: 62
diff changeset
   365
    if (event && event->type() == HbEvent::ThemeChanged) {
hgs
parents: 62
diff changeset
   366
        NmMessageListModelItem *msgModelItem(NULL);
hgs
parents: 62
diff changeset
   367
        msgModelItem = modelIndex().data(
hgs
parents: 62
diff changeset
   368
            Qt::DisplayRole).value<NmMessageListModelItem*>();
hgs
parents: 62
diff changeset
   369
        if (msgModelItem && !msgModelItem->envelope().isRead()) {
hgs
parents: 62
diff changeset
   370
            setFontsUnread();
hgs
parents: 62
diff changeset
   371
        }
hgs
parents: 62
diff changeset
   372
        else if (msgModelItem) {
hgs
parents: 62
diff changeset
   373
            setFontsRead();
hgs
parents: 62
diff changeset
   374
        }
hgs
parents: 62
diff changeset
   375
    }
hgs
parents: 62
diff changeset
   376
    return ret;
hgs
parents: 62
diff changeset
   377
}
hgs
parents: 62
diff changeset
   378