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