emailuis/nmailui/src/nmeditorheader.cpp
author hgs
Tue, 29 Jun 2010 17:12:28 +0300
changeset 48 10eaf342f539
parent 47 f83bd4ae1fe3
child 51 d845db10c0d4
permissions -rw-r--r--
201025_1
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";
hgs
parents: 40
diff changeset
    25
static const char *NMUI_EDITOR_CC_FIELD = "editorCcField";
hgs
parents: 40
diff changeset
    26
static const char *NMUI_EDITOR_BCC_FIELD = "editorBccField";
hgs
parents: 40
diff changeset
    27
static const char *NMUI_EDITOR_PRIORITY_ICON = "editPriorityIcon";
hgs
parents: 40
diff changeset
    28
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
    29
static const char *NMUI_EDITOR_ATTACHMENT_LIST = "attachmentListWidget";
43
hgs
parents: 40
diff changeset
    30
static const char *NMUI_EDITOR_PREFIX_TO = "editorTo";
hgs
parents: 40
diff changeset
    31
static const char *NMUI_EDITOR_PREFIX_CC = "editorCc";
hgs
parents: 40
diff changeset
    32
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
    33
47
hgs
parents: 44
diff changeset
    34
static const int NmMaxRows = 10000;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
44
hgs
parents: 43
diff changeset
    36
// this timeout seems to be long enough for all cases. see sendDelayedHeaderHeightChanged
47
hgs
parents: 44
diff changeset
    37
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
    38
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
    Constructor
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
*/
47
hgs
parents: 44
diff changeset
    42
NmEditorHeader::NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader) :
hgs
parents: 44
diff changeset
    43
    QObject(parent),
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
    mDocumentLoader(documentLoader),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    mHeaderHeight(0),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
    mIconVisible(false),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
    mSubjectEdit(NULL),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    mRecipientFieldsEmpty(true),
40
hgs
parents: 23
diff changeset
    49
    mAttachmentList(NULL),
hgs
parents: 23
diff changeset
    50
    mToField(NULL),
hgs
parents: 23
diff changeset
    51
    mCcField(NULL),
hgs
parents: 23
diff changeset
    52
    mBccField(NULL),
hgs
parents: 23
diff changeset
    53
    mCcBccFieldVisible(false)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
{
43
hgs
parents: 40
diff changeset
    55
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    56
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
    loadWidgets();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    createConnections();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    Destructor
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
NmEditorHeader::~NmEditorHeader()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
{
43
hgs
parents: 40
diff changeset
    66
    NM_FUNCTION;
18
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
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
    Load widgets from XML for the header.
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
void NmEditorHeader::loadWidgets()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
{
43
hgs
parents: 40
diff changeset
    74
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    75
	
hgs
parents: 40
diff changeset
    76
    // Load widgets from docml and construct handlers. Those widgets that are not shown by default
hgs
parents: 40
diff changeset
    77
    // are hidden and removed from the layout at this phase.    
hgs
parents: 40
diff changeset
    78
    HbWidget *contentWidget =
hgs
parents: 40
diff changeset
    79
        qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CONTAINER));
47
hgs
parents: 44
diff changeset
    80
    if (contentWidget) {
hgs
parents: 44
diff changeset
    81
        mLayout = static_cast<QGraphicsLinearLayout *>(contentWidget->layout());
hgs
parents: 44
diff changeset
    82
    
hgs
parents: 44
diff changeset
    83
        // base class QObject takes the deleting responsibility
hgs
parents: 44
diff changeset
    84
        mToField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_TO);
hgs
parents: 44
diff changeset
    85
        mCcField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_CC);
hgs
parents: 44
diff changeset
    86
        mBccField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_BCC);
hgs
parents: 44
diff changeset
    87
    
hgs
parents: 44
diff changeset
    88
        // Sets up editor properties like no prediction, lower case preferred etc.
hgs
parents: 44
diff changeset
    89
        HbEditorInterface toEditorInterface(mToField->editor());
hgs
parents: 44
diff changeset
    90
        HbEditorInterface ccEditorInterface(mCcField->editor());
hgs
parents: 44
diff changeset
    91
        HbEditorInterface bccEditorInterface(mBccField->editor());
hgs
parents: 44
diff changeset
    92
        toEditorInterface.setUpAsLatinAlphabetOnlyEditor();
hgs
parents: 44
diff changeset
    93
        ccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
hgs
parents: 44
diff changeset
    94
        bccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
40
hgs
parents: 23
diff changeset
    95
47
hgs
parents: 44
diff changeset
    96
        // Cc field is not shown by default. It needs to be both hidden and removed from the layout.
hgs
parents: 44
diff changeset
    97
        mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD));
hgs
parents: 44
diff changeset
    98
        mCcWidget->hide();
hgs
parents: 44
diff changeset
    99
        mLayout->removeItem(mCcWidget);
hgs
parents: 44
diff changeset
   100
          
hgs
parents: 44
diff changeset
   101
        // Bcc field is not shown by default. It needs to be both hidden and removed from the layout.
hgs
parents: 44
diff changeset
   102
        mBccWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_BCC_FIELD));
hgs
parents: 44
diff changeset
   103
        mBccWidget->hide();
hgs
parents: 44
diff changeset
   104
        mLayout->removeItem(mBccWidget);
43
hgs
parents: 40
diff changeset
   105
    
47
hgs
parents: 44
diff changeset
   106
        mSubjectWidget =
hgs
parents: 44
diff changeset
   107
            qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_FIELD));
hgs
parents: 44
diff changeset
   108
        mSubjectLayout = static_cast<QGraphicsLinearLayout *>(mSubjectWidget->layout());
hgs
parents: 44
diff changeset
   109
          
hgs
parents: 44
diff changeset
   110
        // Add Subject: field
hgs
parents: 44
diff changeset
   111
        mSubjectEdit = qobject_cast<NmHtmlLineEdit *>
hgs
parents: 44
diff changeset
   112
            (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT));
hgs
parents: 44
diff changeset
   113
        mSubjectEdit->setMaxRows(NmMaxRows);
hgs
parents: 44
diff changeset
   114
    
hgs
parents: 44
diff changeset
   115
        // Add attachment list
hgs
parents: 44
diff changeset
   116
        NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *>
hgs
parents: 44
diff changeset
   117
            (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST));
hgs
parents: 44
diff changeset
   118
        // Create attachment list handling object
hgs
parents: 44
diff changeset
   119
        mAttachmentList = new NmAttachmentList(*attachmentList);
hgs
parents: 44
diff changeset
   120
        mAttachmentList->setParent(this); // ownership changes
hgs
parents: 44
diff changeset
   121
        attachmentList->hide();
hgs
parents: 44
diff changeset
   122
        mLayout->removeItem(attachmentList);
hgs
parents: 44
diff changeset
   123
    
hgs
parents: 44
diff changeset
   124
        // Add priority icon
hgs
parents: 44
diff changeset
   125
        mPriorityIcon = qobject_cast<HbLabel *>
hgs
parents: 44
diff changeset
   126
            (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON));
hgs
parents: 44
diff changeset
   127
        mPriorityIcon->hide();
hgs
parents: 44
diff changeset
   128
        mSubjectLayout->removeItem(mPriorityIcon);
hgs
parents: 44
diff changeset
   129
    
hgs
parents: 44
diff changeset
   130
        // follow-up icon is not yet supported
hgs
parents: 44
diff changeset
   131
        HbLabel *followUpIcon = qobject_cast<HbLabel *>
hgs
parents: 44
diff changeset
   132
            (mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON));
hgs
parents: 44
diff changeset
   133
        followUpIcon->hide();
hgs
parents: 44
diff changeset
   134
        mSubjectLayout->removeItem(followUpIcon);    
hgs
parents: 44
diff changeset
   135
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
    Create signal - slot connections.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
void NmEditorHeader::createConnections()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
{
43
hgs
parents: 40
diff changeset
   143
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   144
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    // 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
   146
    connect(mToField, SIGNAL(textChanged(const QString &)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
            this, SLOT(editorContentChanged()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    connect(mCcField, SIGNAL(textChanged(const QString &)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
            this, SLOT(editorContentChanged()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
    connect(mBccField, SIGNAL(textChanged(const QString &)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
            this, SLOT(editorContentChanged()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    // Signals for handling the recipient field expanding
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    connect(mToField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   155
            this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    connect(mCcField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   157
            this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    connect(mBccField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   159
            this, SLOT(sendDelayedHeaderHeightChanged()));
hgs
parents: 40
diff changeset
   160
    connect(mSubjectEdit, SIGNAL(contentsChanged()), this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    // Signals for handling the attachment list
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   163
    connect(&mAttachmentList->listWidget(), SIGNAL(itemActivated(int)),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   164
            this, SLOT(attachmentActivated(int)));
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   165
    connect(&mAttachmentList->listWidget(), SIGNAL(longPressed(int, QPointF)),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   166
            this, SLOT(attachmentLongPressed(int, QPointF)));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
/*!
40
hgs
parents: 23
diff changeset
   170
   Show or hide recipient field
hgs
parents: 23
diff changeset
   171
*/
hgs
parents: 23
diff changeset
   172
void NmEditorHeader::setFieldVisibility(bool isVisible)
hgs
parents: 23
diff changeset
   173
{
hgs
parents: 23
diff changeset
   174
	if ( mCcBccFieldVisible != isVisible ) {
hgs
parents: 23
diff changeset
   175
		mCcBccFieldVisible = isVisible;
hgs
parents: 23
diff changeset
   176
		if (mCcBccFieldVisible) {
43
hgs
parents: 40
diff changeset
   177
            mLayout->insertItem(1, mBccWidget);
hgs
parents: 40
diff changeset
   178
			mLayout->insertItem(1, mCcWidget);
hgs
parents: 40
diff changeset
   179
			mCcWidget->show();
hgs
parents: 40
diff changeset
   180
            mBccWidget->show();
40
hgs
parents: 23
diff changeset
   181
		}
hgs
parents: 23
diff changeset
   182
		else {
43
hgs
parents: 40
diff changeset
   183
            mCcWidget->hide();
hgs
parents: 40
diff changeset
   184
            mBccWidget->hide();
hgs
parents: 40
diff changeset
   185
			mLayout->removeItem(mCcWidget);
hgs
parents: 40
diff changeset
   186
			mLayout->removeItem(mBccWidget);
40
hgs
parents: 23
diff changeset
   187
		}
44
hgs
parents: 43
diff changeset
   188
        sendDelayedHeaderHeightChanged();
40
hgs
parents: 23
diff changeset
   189
	}
hgs
parents: 23
diff changeset
   190
}
hgs
parents: 23
diff changeset
   191
hgs
parents: 23
diff changeset
   192
/*!
47
hgs
parents: 44
diff changeset
   193
    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
   194
 */
43
hgs
parents: 40
diff changeset
   195
qreal NmEditorHeader::headerHeight() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
{
43
hgs
parents: 40
diff changeset
   197
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   198
hgs
parents: 40
diff changeset
   199
    // get the layout's vertical spacing
hgs
parents: 40
diff changeset
   200
    qreal spacing = 0;
hgs
parents: 40
diff changeset
   201
    HbStyle().parameter("hb-param-margin-gene-middle-vertical", spacing);
hgs
parents: 40
diff changeset
   202
hgs
parents: 40
diff changeset
   203
    // calculate the height
hgs
parents: 40
diff changeset
   204
    qreal height = 0;
hgs
parents: 40
diff changeset
   205
    
hgs
parents: 40
diff changeset
   206
    height += mToField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   207
    height += spacing;
hgs
parents: 40
diff changeset
   208
    
40
hgs
parents: 23
diff changeset
   209
    if (mCcBccFieldVisible) {
43
hgs
parents: 40
diff changeset
   210
        height += mCcField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   211
        height += spacing;
hgs
parents: 40
diff changeset
   212
        
hgs
parents: 40
diff changeset
   213
        height += mBccField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   214
        height += spacing;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
43
hgs
parents: 40
diff changeset
   217
    height += mSubjectWidget->geometry().height();
hgs
parents: 40
diff changeset
   218
    height += spacing;
hgs
parents: 40
diff changeset
   219
hgs
parents: 40
diff changeset
   220
    if (mAttachmentList->listWidget().isVisible()) {
hgs
parents: 40
diff changeset
   221
        height += mAttachmentList->listWidget().geometry().height();
hgs
parents: 40
diff changeset
   222
        height += spacing;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
43
hgs
parents: 40
diff changeset
   225
    return height;
40
hgs
parents: 23
diff changeset
   226
}
hgs
parents: 23
diff changeset
   227
hgs
parents: 23
diff changeset
   228
/*!
44
hgs
parents: 43
diff changeset
   229
    This is called when the contents of some of the header widgets have been changed. When the
hgs
parents: 43
diff changeset
   230
    contents change the widget's actual size may also change. The header area height is needed to
hgs
parents: 43
diff changeset
   231
    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
   232
    the Orbit FW adjust the heights eg. if the subject and recipient fields are expanded by the FW.
hgs
parents: 43
diff changeset
   233
    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
   234
    information.
40
hgs
parents: 23
diff changeset
   235
 */
43
hgs
parents: 40
diff changeset
   236
void NmEditorHeader::sendDelayedHeaderHeightChanged()
40
hgs
parents: 23
diff changeset
   237
{
43
hgs
parents: 40
diff changeset
   238
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   239
	QTimer::singleShot(NmLayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
}
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
/*!
44
hgs
parents: 43
diff changeset
   243
    Send a signal that the header area height has been changed if necessary. This is needed for the
hgs
parents: 43
diff changeset
   244
    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
   245
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
void NmEditorHeader::sendHeaderHeightChanged()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
{
43
hgs
parents: 40
diff changeset
   248
    qreal hHeight = headerHeight();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
    if (mHeaderHeight != hHeight) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
        mHeaderHeight = hHeight;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
        emit headerHeightChanged(mHeaderHeight);
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
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
/*!
40
hgs
parents: 23
diff changeset
   256
    Return pointer to to edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
 */
40
hgs
parents: 23
diff changeset
   258
NmRecipientLineEdit* NmEditorHeader::toEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
{
43
hgs
parents: 40
diff changeset
   260
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   261
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
    return mToField->editor();
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
/*!
40
hgs
parents: 23
diff changeset
   266
    Return pointer to cc edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
 */
40
hgs
parents: 23
diff changeset
   268
NmRecipientLineEdit* NmEditorHeader::ccEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
{
43
hgs
parents: 40
diff changeset
   270
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   271
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    return mCcField->editor();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
/*!
40
hgs
parents: 23
diff changeset
   276
    Return pointer to bcc edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
 */
40
hgs
parents: 23
diff changeset
   278
NmRecipientLineEdit* NmEditorHeader::bccEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
{
43
hgs
parents: 40
diff changeset
   280
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   281
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
    return mBccField->editor();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
    Return pointer to subject field
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
 */
40
hgs
parents: 23
diff changeset
   288
NmHtmlLineEdit* NmEditorHeader::subjectEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
{
43
hgs
parents: 40
diff changeset
   290
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   291
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
    return mSubjectEdit;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
    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
   297
    the state is changed.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
void NmEditorHeader::editorContentChanged()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
{
43
hgs
parents: 40
diff changeset
   301
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   302
    
47
hgs
parents: 44
diff changeset
   303
    bool recipientsFieldsEmpty(true);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    if (mToField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
        recipientsFieldsEmpty = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    else if (mCcField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
        recipientsFieldsEmpty = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    else if (mBccField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
        recipientsFieldsEmpty = false;
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
    if (mRecipientFieldsEmpty != recipientsFieldsEmpty) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
        mRecipientFieldsEmpty = recipientsFieldsEmpty;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
        emit recipientFieldsHaveContent(!mRecipientFieldsEmpty);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
    Sets the icon for priority
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
void NmEditorHeader::setPriority(NmMessagePriority priority)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
{
43
hgs
parents: 40
diff changeset
   324
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   325
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
    switch (priority) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    case NmMessagePriorityHigh:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
        setPriority(NmActionResponseCommandPriorityHigh);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    case NmMessagePriorityLow:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
        setPriority(NmActionResponseCommandPriorityLow);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
    default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
        setPriority(NmActionResponseCommandNone);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
    }
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
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
    Sets the icon for priority
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
void NmEditorHeader::setPriority(NmActionResponseCommand prio)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
{
43
hgs
parents: 40
diff changeset
   344
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   345
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
    switch(prio) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
    case NmActionResponseCommandPriorityHigh:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
        if (!mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
            mIconVisible = true;
43
hgs
parents: 40
diff changeset
   350
            // icon widget is just after the subject line edit (see docml)
hgs
parents: 40
diff changeset
   351
            mSubjectLayout->insertItem(2, mPriorityIcon);
hgs
parents: 40
diff changeset
   352
            mPriorityIcon->show();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
        }
43
hgs
parents: 40
diff changeset
   354
        mPriorityIcon->setIcon(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
            NmIcons::getIcon(NmIcons::NmIconPriorityHigh));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
    case NmActionResponseCommandPriorityLow:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
        if (!mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
            mIconVisible = true;
43
hgs
parents: 40
diff changeset
   360
            // icon widget is just after the subject line edit (see docml)
hgs
parents: 40
diff changeset
   361
            mSubjectLayout->insertItem(2, mPriorityIcon);
hgs
parents: 40
diff changeset
   362
            mPriorityIcon->show();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
        }
43
hgs
parents: 40
diff changeset
   364
        mPriorityIcon->setIcon(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
            NmIcons::getIcon(NmIcons::NmIconPriorityLow));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
    default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
        if (mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
            mIconVisible = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
            HbIcon emptyIcon;
43
hgs
parents: 40
diff changeset
   371
            mPriorityIcon->setIcon(emptyIcon);
hgs
parents: 40
diff changeset
   372
            mSubjectLayout->removeItem(mPriorityIcon);
hgs
parents: 40
diff changeset
   373
            mPriorityIcon->hide();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
    }
44
hgs
parents: 43
diff changeset
   377
    sendDelayedHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
   Adds an attachment to attachment list for mail.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
void NmEditorHeader::addAttachment(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    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
   385
{
43
hgs
parents: 40
diff changeset
   386
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   387
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
    mAttachmentList->insertAttachment(fileName, fileSize, nmid);
43
hgs
parents: 40
diff changeset
   389
    if (!mAttachmentList->listWidget().isVisible()) {
hgs
parents: 40
diff changeset
   390
        // attachment list is inserted just before the body widget (see docml).
hgs
parents: 40
diff changeset
   391
        mLayout->insertItem(mLayout->count() - 1, &mAttachmentList->listWidget());
hgs
parents: 40
diff changeset
   392
        mAttachmentList->listWidget().show();
hgs
parents: 40
diff changeset
   393
    }
47
hgs
parents: 44
diff changeset
   394
    sendHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   398
   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
   399
   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
   400
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
void NmEditorHeader::removeAttachment(const QString &fileName)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
{
43
hgs
parents: 40
diff changeset
   403
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   404
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
    mAttachmentList->removeAttachment(fileName);
43
hgs
parents: 40
diff changeset
   406
    if (mAttachmentList->count() == 0) {
hgs
parents: 40
diff changeset
   407
        mAttachmentList->listWidget().hide();
hgs
parents: 40
diff changeset
   408
        mLayout->removeItem(&mAttachmentList->listWidget());
hgs
parents: 40
diff changeset
   409
    }
44
hgs
parents: 43
diff changeset
   410
    sendDelayedHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   414
   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
   415
   attachment has been selected for remove.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   416
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   417
void NmEditorHeader::removeAttachment(const NmId &nmid)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   418
{
43
hgs
parents: 40
diff changeset
   419
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   420
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   421
    mAttachmentList->removeAttachment(nmid);
44
hgs
parents: 43
diff changeset
   422
    if (mAttachmentList->count() == 0) {
hgs
parents: 43
diff changeset
   423
        mAttachmentList->listWidget().hide();
hgs
parents: 43
diff changeset
   424
        mLayout->removeItem(&mAttachmentList->listWidget());
hgs
parents: 43
diff changeset
   425
    }
hgs
parents: 43
diff changeset
   426
    sendDelayedHeaderHeightChanged();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   427
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   428
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   429
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
    This function set messagePartId and fileSize for attachment.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
void NmEditorHeader::setAttachmentParameters(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
    const QString &fileName,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
    const NmId &msgPartId,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    const QString &fileSize,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
    int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
{
43
hgs
parents: 40
diff changeset
   438
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   439
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    if (result == NmNoError) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
        // 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
   442
        mAttachmentList->setAttachmentPartId(fileName, msgPartId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
        mAttachmentList->setAttachmentSize(msgPartId, fileSize);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   448
   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
   449
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   450
void NmEditorHeader::attachmentActivated(int arrayIndex)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   451
{
43
hgs
parents: 40
diff changeset
   452
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   453
44
hgs
parents: 43
diff changeset
   454
    emit attachmentShortPressed(mAttachmentList->nmIdByIndex(arrayIndex));    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   455
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   456
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   457
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
   Slot attachment selected from attachment list by longtap.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
 */
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   460
void NmEditorHeader::attachmentLongPressed(int arrayIndex, QPointF point)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
{
43
hgs
parents: 40
diff changeset
   462
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   463
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
    // Remove selected attachment
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   465
    emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467