emailuis/nmailui/src/nmeditorheader.cpp
author hgs
Thu, 30 Sep 2010 11:43:07 +0300
changeset 74 6c59112cfd31
parent 66 084b5b1f02a7
permissions -rw-r--r--
201039
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
/*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
43
hgs
parents: 40
diff changeset
    14
* Description: Message editor header container class. Collects the header widgets.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
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
// Layout
43
hgs
parents: 40
diff changeset
    21
// These match to the defintions in nmeditorview.docml
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
    22
static const char *NMUI_EDITOR_CONTAINER = "scrollAreaContents";
43
hgs
parents: 40
diff changeset
    23
static const char *NMUI_EDITOR_SUBJECT_FIELD = "editorSubjectField";
hgs
parents: 40
diff changeset
    24
static const char *NMUI_EDITOR_SUBJECT_EDIT = "editorSubjectEdit";
74
hgs
parents: 66
diff changeset
    25
static const char *NMUI_EDITOR_SUBJECT_LABEL = "editorSubjectLabel";
51
hgs
parents: 48
diff changeset
    26
static const char *NMUI_EDITOR_TO_FIELD = "editorToField";
43
hgs
parents: 40
diff changeset
    27
static const char *NMUI_EDITOR_CC_FIELD = "editorCcField";
hgs
parents: 40
diff changeset
    28
static const char *NMUI_EDITOR_BCC_FIELD = "editorBccField";
hgs
parents: 40
diff changeset
    29
static const char *NMUI_EDITOR_PRIORITY_ICON = "editPriorityIcon";
hgs
parents: 40
diff changeset
    30
static const char *NMUI_EDITOR_FOLLOWUP_ICON = "editFollowUpIcon";
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
static const char *NMUI_EDITOR_ATTACHMENT_LIST = "attachmentListWidget";
43
hgs
parents: 40
diff changeset
    32
static const char *NMUI_EDITOR_PREFIX_TO = "editorTo";
hgs
parents: 40
diff changeset
    33
static const char *NMUI_EDITOR_PREFIX_CC = "editorCc";
hgs
parents: 40
diff changeset
    34
static const char *NMUI_EDITOR_PREFIX_BCC = "editorBcc";
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
47
hgs
parents: 44
diff changeset
    36
static const int NmMaxRows = 10000;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
44
hgs
parents: 43
diff changeset
    38
// this timeout seems to be long enough for all cases. see sendDelayedHeaderHeightChanged
47
hgs
parents: 44
diff changeset
    39
static const int NmLayoutSystemWaitTimer = 500; // 0.5 sec
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
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
    Constructor
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
*/
51
hgs
parents: 48
diff changeset
    44
NmEditorHeader::NmEditorHeader(
hgs
parents: 48
diff changeset
    45
    QObject *parent, NmApplication &application, HbDocumentLoader *documentLoader) :
47
hgs
parents: 44
diff changeset
    46
    QObject(parent),
51
hgs
parents: 48
diff changeset
    47
    mApplication(application),
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    mDocumentLoader(documentLoader),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
    mHeaderHeight(0),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
    mIconVisible(false),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
    mSubjectEdit(NULL),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
    mRecipientFieldsEmpty(true),
40
hgs
parents: 23
diff changeset
    53
    mAttachmentList(NULL),
hgs
parents: 23
diff changeset
    54
    mToField(NULL),
hgs
parents: 23
diff changeset
    55
    mCcField(NULL),
hgs
parents: 23
diff changeset
    56
    mBccField(NULL),
hgs
parents: 23
diff changeset
    57
    mCcBccFieldVisible(false)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
{
43
hgs
parents: 40
diff changeset
    59
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    60
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
    loadWidgets();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    createConnections();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
}
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
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
    Destructor
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
NmEditorHeader::~NmEditorHeader()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
{
43
hgs
parents: 40
diff changeset
    70
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
    Load widgets from XML for the header.
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
void NmEditorHeader::loadWidgets()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
{
43
hgs
parents: 40
diff changeset
    78
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    79
	
hgs
parents: 40
diff changeset
    80
    // Load widgets from docml and construct handlers. Those widgets that are not shown by default
hgs
parents: 40
diff changeset
    81
    // are hidden and removed from the layout at this phase.    
hgs
parents: 40
diff changeset
    82
    HbWidget *contentWidget =
hgs
parents: 40
diff changeset
    83
        qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CONTAINER));
47
hgs
parents: 44
diff changeset
    84
    if (contentWidget) {
hgs
parents: 44
diff changeset
    85
        mLayout = static_cast<QGraphicsLinearLayout *>(contentWidget->layout());
hgs
parents: 44
diff changeset
    86
    
hgs
parents: 44
diff changeset
    87
        // base class QObject takes the deleting responsibility
hgs
parents: 44
diff changeset
    88
        mToField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_TO);
hgs
parents: 44
diff changeset
    89
        mCcField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_CC);
hgs
parents: 44
diff changeset
    90
        mBccField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_BCC);
74
hgs
parents: 66
diff changeset
    91
        // Connection for adjusting recipient field labels. Connection done earlier than other connections
hgs
parents: 66
diff changeset
    92
        // so that we don't miss signal.
hgs
parents: 66
diff changeset
    93
        connect(mToField->editor(), SIGNAL(layoutChanged ()), this, SLOT(toFieldLayoutReady()));
47
hgs
parents: 44
diff changeset
    94
    
hgs
parents: 44
diff changeset
    95
        // Sets up editor properties like no prediction, lower case preferred etc.
hgs
parents: 44
diff changeset
    96
        HbEditorInterface toEditorInterface(mToField->editor());
hgs
parents: 44
diff changeset
    97
        HbEditorInterface ccEditorInterface(mCcField->editor());
hgs
parents: 44
diff changeset
    98
        HbEditorInterface bccEditorInterface(mBccField->editor());
hgs
parents: 44
diff changeset
    99
        toEditorInterface.setUpAsLatinAlphabetOnlyEditor();
hgs
parents: 44
diff changeset
   100
        ccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
hgs
parents: 44
diff changeset
   101
        bccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
40
hgs
parents: 23
diff changeset
   102
51
hgs
parents: 48
diff changeset
   103
        mToWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_TO_FIELD));
hgs
parents: 48
diff changeset
   104
        
47
hgs
parents: 44
diff changeset
   105
        // Cc field is not shown by default. It needs to be both hidden and removed from the layout.
hgs
parents: 44
diff changeset
   106
        mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD));
hgs
parents: 44
diff changeset
   107
        mCcWidget->hide();
hgs
parents: 44
diff changeset
   108
        mLayout->removeItem(mCcWidget);
hgs
parents: 44
diff changeset
   109
          
hgs
parents: 44
diff changeset
   110
        // Bcc field is not shown by default. It needs to be both hidden and removed from the layout.
hgs
parents: 44
diff changeset
   111
        mBccWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_BCC_FIELD));
hgs
parents: 44
diff changeset
   112
        mBccWidget->hide();
hgs
parents: 44
diff changeset
   113
        mLayout->removeItem(mBccWidget);
43
hgs
parents: 40
diff changeset
   114
    
47
hgs
parents: 44
diff changeset
   115
        mSubjectWidget =
hgs
parents: 44
diff changeset
   116
            qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_FIELD));
hgs
parents: 44
diff changeset
   117
        mSubjectLayout = static_cast<QGraphicsLinearLayout *>(mSubjectWidget->layout());
74
hgs
parents: 66
diff changeset
   118
        mSubjectLabel =
hgs
parents: 66
diff changeset
   119
            qobject_cast<HbLabel *>(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_LABEL));
47
hgs
parents: 44
diff changeset
   120
          
hgs
parents: 44
diff changeset
   121
        // Add Subject: field
hgs
parents: 44
diff changeset
   122
        mSubjectEdit = qobject_cast<NmHtmlLineEdit *>
hgs
parents: 44
diff changeset
   123
            (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT));
hgs
parents: 44
diff changeset
   124
        mSubjectEdit->setMaxRows(NmMaxRows);
hgs
parents: 44
diff changeset
   125
    
hgs
parents: 44
diff changeset
   126
        // Add attachment list
51
hgs
parents: 48
diff changeset
   127
        mAttachmentListWidget = qobject_cast<NmAttachmentListWidget *>
47
hgs
parents: 44
diff changeset
   128
            (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST));
hgs
parents: 44
diff changeset
   129
        // Create attachment list handling object
51
hgs
parents: 48
diff changeset
   130
        mAttachmentList = new NmAttachmentList(*mAttachmentListWidget);
47
hgs
parents: 44
diff changeset
   131
        mAttachmentList->setParent(this); // ownership changes
51
hgs
parents: 48
diff changeset
   132
        mAttachmentListWidget->hide();
57
hgs
parents: 56
diff changeset
   133
        mLayout->removeItem(&mAttachmentList->listWidget());
47
hgs
parents: 44
diff changeset
   134
    
hgs
parents: 44
diff changeset
   135
        // Add priority icon
hgs
parents: 44
diff changeset
   136
        mPriorityIcon = qobject_cast<HbLabel *>
hgs
parents: 44
diff changeset
   137
            (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON));
hgs
parents: 44
diff changeset
   138
        mPriorityIcon->hide();
hgs
parents: 44
diff changeset
   139
        mSubjectLayout->removeItem(mPriorityIcon);
hgs
parents: 44
diff changeset
   140
    
hgs
parents: 44
diff changeset
   141
        // follow-up icon is not yet supported
hgs
parents: 44
diff changeset
   142
        HbLabel *followUpIcon = qobject_cast<HbLabel *>
hgs
parents: 44
diff changeset
   143
            (mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON));
hgs
parents: 44
diff changeset
   144
        followUpIcon->hide();
hgs
parents: 44
diff changeset
   145
        mSubjectLayout->removeItem(followUpIcon);    
hgs
parents: 44
diff changeset
   146
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
    Create signal - slot connections.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
void NmEditorHeader::createConnections()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
{
43
hgs
parents: 40
diff changeset
   154
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   155
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    // Signals for checking if the recipient fields have text.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    connect(mToField, SIGNAL(textChanged(const QString &)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
            this, SLOT(editorContentChanged()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    connect(mCcField, SIGNAL(textChanged(const QString &)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
            this, SLOT(editorContentChanged()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    connect(mBccField, SIGNAL(textChanged(const QString &)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
            this, SLOT(editorContentChanged()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
    // Signals for handling the recipient field expanding
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    connect(mToField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   166
            this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    connect(mCcField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   168
            this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    connect(mBccField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   170
            this, SLOT(sendDelayedHeaderHeightChanged()));
hgs
parents: 40
diff changeset
   171
    connect(mSubjectEdit, SIGNAL(contentsChanged()), this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    // Signals for handling the attachment list
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   174
    connect(&mAttachmentList->listWidget(), SIGNAL(itemActivated(int)),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   175
            this, SLOT(attachmentActivated(int)));
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   176
    connect(&mAttachmentList->listWidget(), SIGNAL(longPressed(int, QPointF)),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   177
            this, SLOT(attachmentLongPressed(int, QPointF)));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
/*!
40
hgs
parents: 23
diff changeset
   181
   Show or hide recipient field
hgs
parents: 23
diff changeset
   182
*/
hgs
parents: 23
diff changeset
   183
void NmEditorHeader::setFieldVisibility(bool isVisible)
hgs
parents: 23
diff changeset
   184
{
hgs
parents: 23
diff changeset
   185
	if ( mCcBccFieldVisible != isVisible ) {
hgs
parents: 23
diff changeset
   186
		mCcBccFieldVisible = isVisible;
hgs
parents: 23
diff changeset
   187
		if (mCcBccFieldVisible) {
43
hgs
parents: 40
diff changeset
   188
            mLayout->insertItem(1, mBccWidget);
hgs
parents: 40
diff changeset
   189
			mLayout->insertItem(1, mCcWidget);
hgs
parents: 40
diff changeset
   190
			mCcWidget->show();
hgs
parents: 40
diff changeset
   191
            mBccWidget->show();
40
hgs
parents: 23
diff changeset
   192
		}
hgs
parents: 23
diff changeset
   193
		else {
43
hgs
parents: 40
diff changeset
   194
            mCcWidget->hide();
hgs
parents: 40
diff changeset
   195
            mBccWidget->hide();
hgs
parents: 40
diff changeset
   196
			mLayout->removeItem(mCcWidget);
hgs
parents: 40
diff changeset
   197
			mLayout->removeItem(mBccWidget);
40
hgs
parents: 23
diff changeset
   198
		}
44
hgs
parents: 43
diff changeset
   199
        sendDelayedHeaderHeightChanged();
40
hgs
parents: 23
diff changeset
   200
	}
hgs
parents: 23
diff changeset
   201
}
hgs
parents: 23
diff changeset
   202
hgs
parents: 23
diff changeset
   203
/*!
47
hgs
parents: 44
diff changeset
   204
    Return the sum of the header widget heights. This contains all the spacings a well. 
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
 */
43
hgs
parents: 40
diff changeset
   206
qreal NmEditorHeader::headerHeight() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
{
43
hgs
parents: 40
diff changeset
   208
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   209
hgs
parents: 40
diff changeset
   210
    // get the layout's vertical spacing
hgs
parents: 40
diff changeset
   211
    qreal spacing = 0;
66
hgs
parents: 62
diff changeset
   212
    HbInstance::instance()->style()->parameter("hb-param-margin-gene-middle-vertical", spacing);
43
hgs
parents: 40
diff changeset
   213
hgs
parents: 40
diff changeset
   214
    // calculate the height
hgs
parents: 40
diff changeset
   215
    qreal height = 0;
hgs
parents: 40
diff changeset
   216
    
hgs
parents: 40
diff changeset
   217
    height += mToField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   218
    height += spacing;
hgs
parents: 40
diff changeset
   219
    
40
hgs
parents: 23
diff changeset
   220
    if (mCcBccFieldVisible) {
43
hgs
parents: 40
diff changeset
   221
        height += mCcField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   222
        height += spacing;
hgs
parents: 40
diff changeset
   223
        
hgs
parents: 40
diff changeset
   224
        height += mBccField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   225
        height += spacing;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
43
hgs
parents: 40
diff changeset
   228
    height += mSubjectWidget->geometry().height();
hgs
parents: 40
diff changeset
   229
    height += spacing;
hgs
parents: 40
diff changeset
   230
hgs
parents: 40
diff changeset
   231
    if (mAttachmentList->listWidget().isVisible()) {
hgs
parents: 40
diff changeset
   232
        height += mAttachmentList->listWidget().geometry().height();
hgs
parents: 40
diff changeset
   233
        height += spacing;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
43
hgs
parents: 40
diff changeset
   236
    return height;
40
hgs
parents: 23
diff changeset
   237
}
hgs
parents: 23
diff changeset
   238
hgs
parents: 23
diff changeset
   239
/*!
44
hgs
parents: 43
diff changeset
   240
    This is called when the contents of some of the header widgets have been changed. When the
hgs
parents: 43
diff changeset
   241
    contents change the widget's actual size may also change. The header area height is needed to
hgs
parents: 43
diff changeset
   242
    calculate the size hints of the body and the scroll area widgets. We need to use a timer to let 
hgs
parents: 43
diff changeset
   243
    the Orbit FW adjust the heights eg. if the subject and recipient fields are expanded by the FW.
hgs
parents: 43
diff changeset
   244
    It would be best to find a solution which doesn't depend on the header area's actual height size
hgs
parents: 43
diff changeset
   245
    information.
40
hgs
parents: 23
diff changeset
   246
 */
43
hgs
parents: 40
diff changeset
   247
void NmEditorHeader::sendDelayedHeaderHeightChanged()
40
hgs
parents: 23
diff changeset
   248
{
43
hgs
parents: 40
diff changeset
   249
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   250
	QTimer::singleShot(NmLayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
}
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
/*!
44
hgs
parents: 43
diff changeset
   254
    Send a signal that the header area height has been changed if necessary. This is needed for the
hgs
parents: 43
diff changeset
   255
    body and scroll area widgets. See NmEditorTextEdit::setHeaderHeight for more info.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
void NmEditorHeader::sendHeaderHeightChanged()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
{
43
hgs
parents: 40
diff changeset
   259
    qreal hHeight = headerHeight();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
    if (mHeaderHeight != hHeight) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
        mHeaderHeight = hHeight;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
        emit headerHeightChanged(mHeaderHeight);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
/*!
51
hgs
parents: 48
diff changeset
   267
    Because header filds have fixed size policy. This function must be called to set
hgs
parents: 48
diff changeset
   268
    new width for every header field when orintation has been changed.
hgs
parents: 48
diff changeset
   269
 */
hgs
parents: 48
diff changeset
   270
void NmEditorHeader::adjustHeaderWidth()
hgs
parents: 48
diff changeset
   271
{
hgs
parents: 48
diff changeset
   272
    NM_FUNCTION;
hgs
parents: 48
diff changeset
   273
    
hgs
parents: 48
diff changeset
   274
    int newWidth = mApplication.screenSize().width();
hgs
parents: 48
diff changeset
   275
    mToWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   276
    mCcWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   277
    mBccWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   278
    mSubjectWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   279
    mAttachmentListWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   280
    mSubjectWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   281
}
hgs
parents: 48
diff changeset
   282
hgs
parents: 48
diff changeset
   283
/*!
40
hgs
parents: 23
diff changeset
   284
    Return pointer to to edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
 */
40
hgs
parents: 23
diff changeset
   286
NmRecipientLineEdit* NmEditorHeader::toEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
{
43
hgs
parents: 40
diff changeset
   288
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   289
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
    return mToField->editor();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
/*!
40
hgs
parents: 23
diff changeset
   294
    Return pointer to cc edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
 */
40
hgs
parents: 23
diff changeset
   296
NmRecipientLineEdit* NmEditorHeader::ccEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
{
43
hgs
parents: 40
diff changeset
   298
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   299
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    return mCcField->editor();
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
    Return pointer to bcc edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
 */
40
hgs
parents: 23
diff changeset
   306
NmRecipientLineEdit* NmEditorHeader::bccEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
{
43
hgs
parents: 40
diff changeset
   308
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   309
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    return mBccField->editor();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
    Return pointer to subject field
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
 */
40
hgs
parents: 23
diff changeset
   316
NmHtmlLineEdit* NmEditorHeader::subjectEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
{
43
hgs
parents: 40
diff changeset
   318
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   319
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
    return mSubjectEdit;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
    Checks if recipient editors are empty and emits a signal if
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    the state is changed.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
void NmEditorHeader::editorContentChanged()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
{
43
hgs
parents: 40
diff changeset
   329
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   330
    
47
hgs
parents: 44
diff changeset
   331
    bool recipientsFieldsEmpty(true);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
    if (mToField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
        recipientsFieldsEmpty = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
    else if (mCcField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
        recipientsFieldsEmpty = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
    else if (mBccField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
        recipientsFieldsEmpty = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
    if (mRecipientFieldsEmpty != recipientsFieldsEmpty) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
        mRecipientFieldsEmpty = recipientsFieldsEmpty;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
        emit recipientFieldsHaveContent(!mRecipientFieldsEmpty);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
    Sets the icon for priority
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
void NmEditorHeader::setPriority(NmMessagePriority priority)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
{
43
hgs
parents: 40
diff changeset
   352
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   353
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
    switch (priority) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
    case NmMessagePriorityHigh:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
        setPriority(NmActionResponseCommandPriorityHigh);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
    case NmMessagePriorityLow:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
        setPriority(NmActionResponseCommandPriorityLow);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
    default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
        setPriority(NmActionResponseCommandNone);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    Sets the icon for priority
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
void NmEditorHeader::setPriority(NmActionResponseCommand prio)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
{
43
hgs
parents: 40
diff changeset
   372
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   373
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    switch(prio) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
    case NmActionResponseCommandPriorityHigh:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
        if (!mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
            mIconVisible = true;
43
hgs
parents: 40
diff changeset
   378
            // icon widget is just after the subject line edit (see docml)
hgs
parents: 40
diff changeset
   379
            mSubjectLayout->insertItem(2, mPriorityIcon);
hgs
parents: 40
diff changeset
   380
            mPriorityIcon->show();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
        }
43
hgs
parents: 40
diff changeset
   382
        mPriorityIcon->setIcon(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
            NmIcons::getIcon(NmIcons::NmIconPriorityHigh));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
    case NmActionResponseCommandPriorityLow:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
        if (!mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
            mIconVisible = true;
43
hgs
parents: 40
diff changeset
   388
            // icon widget is just after the subject line edit (see docml)
hgs
parents: 40
diff changeset
   389
            mSubjectLayout->insertItem(2, mPriorityIcon);
hgs
parents: 40
diff changeset
   390
            mPriorityIcon->show();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
        }
43
hgs
parents: 40
diff changeset
   392
        mPriorityIcon->setIcon(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
            NmIcons::getIcon(NmIcons::NmIconPriorityLow));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
    default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
        if (mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
            mIconVisible = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
            HbIcon emptyIcon;
43
hgs
parents: 40
diff changeset
   399
            mPriorityIcon->setIcon(emptyIcon);
hgs
parents: 40
diff changeset
   400
            mSubjectLayout->removeItem(mPriorityIcon);
hgs
parents: 40
diff changeset
   401
            mPriorityIcon->hide();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
    }
44
hgs
parents: 43
diff changeset
   405
    sendDelayedHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
   Adds an attachment to attachment list for mail.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
void NmEditorHeader::addAttachment(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
    const QString &fileName, const QString &fileSize, const NmId &nmid)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
{
43
hgs
parents: 40
diff changeset
   414
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   415
    
56
hgs
parents: 51
diff changeset
   416
    mAttachmentList->insertAttachment(fileName, fileSize, nmid);
hgs
parents: 51
diff changeset
   417
    
43
hgs
parents: 40
diff changeset
   418
    if (!mAttachmentList->listWidget().isVisible()) {
57
hgs
parents: 56
diff changeset
   419
        // attachment list is inserted just before the body widget (see docml).
hgs
parents: 56
diff changeset
   420
        mLayout->insertItem(mLayout->count() - 1, &mAttachmentList->listWidget());
43
hgs
parents: 40
diff changeset
   421
        mAttachmentList->listWidget().show();
hgs
parents: 40
diff changeset
   422
    }
51
hgs
parents: 48
diff changeset
   423
47
hgs
parents: 44
diff changeset
   424
    sendHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   428
   Remove attachment from the list. This function is used when
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   429
   attachment adding has failed and attachment id is not known.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
void NmEditorHeader::removeAttachment(const QString &fileName)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
{
43
hgs
parents: 40
diff changeset
   433
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   434
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    mAttachmentList->removeAttachment(fileName);
43
hgs
parents: 40
diff changeset
   436
    if (mAttachmentList->count() == 0) {
hgs
parents: 40
diff changeset
   437
        mAttachmentList->listWidget().hide();
hgs
parents: 40
diff changeset
   438
        mLayout->removeItem(&mAttachmentList->listWidget());
hgs
parents: 40
diff changeset
   439
    }
44
hgs
parents: 43
diff changeset
   440
    sendDelayedHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   444
   Remove attachment from the list. This function is used when
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   445
   attachment has been selected for remove.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   446
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   447
void NmEditorHeader::removeAttachment(const NmId &nmid)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   448
{
43
hgs
parents: 40
diff changeset
   449
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   450
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   451
    mAttachmentList->removeAttachment(nmid);
44
hgs
parents: 43
diff changeset
   452
    if (mAttachmentList->count() == 0) {
hgs
parents: 43
diff changeset
   453
        mAttachmentList->listWidget().hide();
hgs
parents: 43
diff changeset
   454
        mLayout->removeItem(&mAttachmentList->listWidget());
hgs
parents: 43
diff changeset
   455
    }
hgs
parents: 43
diff changeset
   456
    sendDelayedHeaderHeightChanged();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   457
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   458
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   459
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
    This function set messagePartId and fileSize for attachment.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
void NmEditorHeader::setAttachmentParameters(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
    const QString &fileName,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
    const NmId &msgPartId,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
    const QString &fileSize,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
    int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
{
43
hgs
parents: 40
diff changeset
   468
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   469
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
    if (result == NmNoError) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
        // Attachment adding succesful, set message part id and size for attachment
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
        mAttachmentList->setAttachmentPartId(fileName, msgPartId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
        mAttachmentList->setAttachmentSize(msgPartId, fileSize);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   478
   Slot attachment activated from attachment list by short tap.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   479
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   480
void NmEditorHeader::attachmentActivated(int arrayIndex)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   481
{
43
hgs
parents: 40
diff changeset
   482
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   483
44
hgs
parents: 43
diff changeset
   484
    emit attachmentShortPressed(mAttachmentList->nmIdByIndex(arrayIndex));    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   485
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   486
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   487
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
   Slot attachment selected from attachment list by longtap.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
 */
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   490
void NmEditorHeader::attachmentLongPressed(int arrayIndex, QPointF point)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
{
43
hgs
parents: 40
diff changeset
   492
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   493
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
    // Remove selected attachment
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   495
    emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
}
51
hgs
parents: 48
diff changeset
   497
hgs
parents: 48
diff changeset
   498
/*!
62
hgs
parents: 57
diff changeset
   499
    This function is called when scroll position has been changed.
hgs
parents: 57
diff changeset
   500
    Function performs the pre calculated translation to set new positions for header fields
hgs
parents: 57
diff changeset
   501
    so that header stays visible when body is scrolled horizontally.
51
hgs
parents: 48
diff changeset
   502
 */
62
hgs
parents: 57
diff changeset
   503
void NmEditorHeader::repositHeader(const QTransform &transform)
51
hgs
parents: 48
diff changeset
   504
{
hgs
parents: 48
diff changeset
   505
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
    
62
hgs
parents: 57
diff changeset
   507
    mToWidget->setTransform(transform);
hgs
parents: 57
diff changeset
   508
    mCcWidget->setTransform(transform);
hgs
parents: 57
diff changeset
   509
    mBccWidget->setTransform(transform);
hgs
parents: 57
diff changeset
   510
    mSubjectWidget->setTransform(transform);
hgs
parents: 57
diff changeset
   511
    mAttachmentListWidget->setTransform(transform);
51
hgs
parents: 48
diff changeset
   512
}
hgs
parents: 48
diff changeset
   513
74
hgs
parents: 66
diff changeset
   514
/*!
hgs
parents: 66
diff changeset
   515
   This slot will set the geometry, margin and font for the To,Cc,Bcc and Subject
hgs
parents: 66
diff changeset
   516
   labels located inside the edit fields. These adjustments are done to fix label text
hgs
parents: 66
diff changeset
   517
   position so that it is in same lavel than first line of the edit widget.
hgs
parents: 66
diff changeset
   518
   Slot is called once when 'To' field layout is ready after editor startup.
hgs
parents: 66
diff changeset
   519
   Because all fields are similar it is enough to use only 'To' field information
hgs
parents: 66
diff changeset
   520
   to adjust all header fields.
hgs
parents: 66
diff changeset
   521
*/
hgs
parents: 66
diff changeset
   522
void NmEditorHeader::toFieldLayoutReady()
hgs
parents: 66
diff changeset
   523
{
hgs
parents: 66
diff changeset
   524
    NM_FUNCTION;
hgs
parents: 66
diff changeset
   525
    
hgs
parents: 66
diff changeset
   526
    // Set same font for label and edit.
hgs
parents: 66
diff changeset
   527
    QFont editorFont = mToField->editor()->font();
hgs
parents: 66
diff changeset
   528
    mToField->label()->setFont(editorFont);
hgs
parents: 66
diff changeset
   529
    mCcField->label()->setFont(editorFont);
hgs
parents: 66
diff changeset
   530
    mBccField->label()->setFont(editorFont);
hgs
parents: 66
diff changeset
   531
    mSubjectLabel->setFont(editorFont);
hgs
parents: 66
diff changeset
   532
hgs
parents: 66
diff changeset
   533
    // Set same height for label and edit.
hgs
parents: 66
diff changeset
   534
    qreal editorWidgetHeight = mToField->editor()->geometry().height();
hgs
parents: 66
diff changeset
   535
    mToField->label()->setPreferredHeight(editorWidgetHeight);
hgs
parents: 66
diff changeset
   536
    mCcField->label()->setPreferredHeight(editorWidgetHeight);
hgs
parents: 66
diff changeset
   537
    mBccField->label()->setPreferredHeight(editorWidgetHeight);
hgs
parents: 66
diff changeset
   538
    mSubjectLabel->setPreferredHeight(editorWidgetHeight);
hgs
parents: 66
diff changeset
   539
    
hgs
parents: 66
diff changeset
   540
    // Set left margin for labels.
hgs
parents: 66
diff changeset
   541
    qreal leftMargin;
hgs
parents: 66
diff changeset
   542
    mToField->editor()->layout()->getContentsMargins(&leftMargin, 0, 0, 0);
hgs
parents: 66
diff changeset
   543
    mToField->label()->setContentsMargins(leftMargin, 0, 0, 0);
hgs
parents: 66
diff changeset
   544
    mCcField->label()->setContentsMargins(leftMargin, 0, 0, 0);
hgs
parents: 66
diff changeset
   545
    mBccField->label()->setContentsMargins(leftMargin, 0, 0, 0);
hgs
parents: 66
diff changeset
   546
    mSubjectLabel->setContentsMargins(leftMargin, 0, 0, 0);
hgs
parents: 66
diff changeset
   547
    
hgs
parents: 66
diff changeset
   548
    adjustIndentForEditFields();
hgs
parents: 66
diff changeset
   549
}
hgs
parents: 66
diff changeset
   550
hgs
parents: 66
diff changeset
   551
/*!
hgs
parents: 66
diff changeset
   552
   Set the length of the label and the indention of the edit fields (To,Cc,Bcc,Subject) so
hgs
parents: 66
diff changeset
   553
   that there is enough space for the label field.
hgs
parents: 66
diff changeset
   554
*/
hgs
parents: 66
diff changeset
   555
void NmEditorHeader::adjustIndentForEditFields()
hgs
parents: 66
diff changeset
   556
{
hgs
parents: 66
diff changeset
   557
    NM_FUNCTION;
hgs
parents: 66
diff changeset
   558
hgs
parents: 66
diff changeset
   559
    // Get spacing between label and edit.
hgs
parents: 66
diff changeset
   560
    qreal spacingBetweenLabelAndEdit = 0;
hgs
parents: 66
diff changeset
   561
    HbStyle().parameter("hb-param-margin-gene-middle-horizontal", spacingBetweenLabelAndEdit);
hgs
parents: 66
diff changeset
   562
    // Add more space for label right margin. Without this, last letter ':' of the label is not
hgs
parents: 66
diff changeset
   563
    // fit into field.
hgs
parents: 66
diff changeset
   564
    spacingBetweenLabelAndEdit *= 2;
hgs
parents: 66
diff changeset
   565
    
hgs
parents: 66
diff changeset
   566
    // Get font metrics (We assume that every label has same font).
hgs
parents: 66
diff changeset
   567
    QFontMetrics fm(mToField->label()->font());
hgs
parents: 66
diff changeset
   568
    
hgs
parents: 66
diff changeset
   569
    // Set length of the label widgets based on the string width.
hgs
parents: 66
diff changeset
   570
    // Also set indent for the first line of the edit widget.
hgs
parents: 66
diff changeset
   571
    qreal textWidth = 0;
hgs
parents: 66
diff changeset
   572
    textWidth = fm.width(mToField->label()->plainText()) + spacingBetweenLabelAndEdit;
hgs
parents: 66
diff changeset
   573
    mToField->label()->setPreferredWidth(textWidth);    
hgs
parents: 66
diff changeset
   574
    mToField->editor()->setIndentForLabel(textWidth);    
hgs
parents: 66
diff changeset
   575
    
hgs
parents: 66
diff changeset
   576
    textWidth = fm.width(mCcField->label()->plainText()) + spacingBetweenLabelAndEdit;
hgs
parents: 66
diff changeset
   577
    mCcField->label()->setPreferredWidth(textWidth);
hgs
parents: 66
diff changeset
   578
    mCcField->editor()->setIndentForLabel(textWidth);
hgs
parents: 66
diff changeset
   579
hgs
parents: 66
diff changeset
   580
    textWidth = fm.width(mBccField->label()->plainText()) + spacingBetweenLabelAndEdit;
hgs
parents: 66
diff changeset
   581
    mBccField->label()->setPreferredWidth(textWidth);
hgs
parents: 66
diff changeset
   582
    mBccField->editor()->setIndentForLabel(textWidth);
hgs
parents: 66
diff changeset
   583
    
hgs
parents: 66
diff changeset
   584
    textWidth = fm.width(mSubjectLabel->plainText()) + spacingBetweenLabelAndEdit;
hgs
parents: 66
diff changeset
   585
    mSubjectLabel->setPreferredWidth(textWidth);
hgs
parents: 66
diff changeset
   586
    mSubjectEdit->setIndentForLabel(textWidth);
hgs
parents: 66
diff changeset
   587
}