emailuis/nmailui/src/nmeditorheader.cpp
author hgs
Fri, 23 Jul 2010 19:09:50 +0300
changeset 56 15bc1d5d6267
parent 51 d845db10c0d4
child 57 ae34e1715e21
permissions -rw-r--r--
201029
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();
47
hgs
parents: 44
diff changeset
   127
    
hgs
parents: 44
diff changeset
   128
        // Add priority icon
hgs
parents: 44
diff changeset
   129
        mPriorityIcon = qobject_cast<HbLabel *>
hgs
parents: 44
diff changeset
   130
            (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON));
hgs
parents: 44
diff changeset
   131
        mPriorityIcon->hide();
hgs
parents: 44
diff changeset
   132
        mSubjectLayout->removeItem(mPriorityIcon);
hgs
parents: 44
diff changeset
   133
    
hgs
parents: 44
diff changeset
   134
        // follow-up icon is not yet supported
hgs
parents: 44
diff changeset
   135
        HbLabel *followUpIcon = qobject_cast<HbLabel *>
hgs
parents: 44
diff changeset
   136
            (mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON));
hgs
parents: 44
diff changeset
   137
        followUpIcon->hide();
hgs
parents: 44
diff changeset
   138
        mSubjectLayout->removeItem(followUpIcon);    
hgs
parents: 44
diff changeset
   139
    }
18
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
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
    Create signal - slot connections.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
void NmEditorHeader::createConnections()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
{
43
hgs
parents: 40
diff changeset
   147
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   148
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
    // 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
   150
    connect(mToField, 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
    connect(mCcField, SIGNAL(textChanged(const QString &)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
            this, SLOT(editorContentChanged()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    connect(mBccField, SIGNAL(textChanged(const QString &)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
            this, SLOT(editorContentChanged()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    // Signals for handling the recipient field expanding
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    connect(mToField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   159
            this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    connect(mCcField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   161
            this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    connect(mBccField, SIGNAL(textChanged(const QString &)),
43
hgs
parents: 40
diff changeset
   163
            this, SLOT(sendDelayedHeaderHeightChanged()));
hgs
parents: 40
diff changeset
   164
    connect(mSubjectEdit, SIGNAL(contentsChanged()), this, SLOT(sendDelayedHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    // Signals for handling the attachment list
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   167
    connect(&mAttachmentList->listWidget(), SIGNAL(itemActivated(int)),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   168
            this, SLOT(attachmentActivated(int)));
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   169
    connect(&mAttachmentList->listWidget(), SIGNAL(longPressed(int, QPointF)),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   170
            this, SLOT(attachmentLongPressed(int, QPointF)));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
}
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
/*!
40
hgs
parents: 23
diff changeset
   174
   Show or hide recipient field
hgs
parents: 23
diff changeset
   175
*/
hgs
parents: 23
diff changeset
   176
void NmEditorHeader::setFieldVisibility(bool isVisible)
hgs
parents: 23
diff changeset
   177
{
hgs
parents: 23
diff changeset
   178
	if ( mCcBccFieldVisible != isVisible ) {
hgs
parents: 23
diff changeset
   179
		mCcBccFieldVisible = isVisible;
hgs
parents: 23
diff changeset
   180
		if (mCcBccFieldVisible) {
43
hgs
parents: 40
diff changeset
   181
            mLayout->insertItem(1, mBccWidget);
hgs
parents: 40
diff changeset
   182
			mLayout->insertItem(1, mCcWidget);
hgs
parents: 40
diff changeset
   183
			mCcWidget->show();
hgs
parents: 40
diff changeset
   184
            mBccWidget->show();
40
hgs
parents: 23
diff changeset
   185
		}
hgs
parents: 23
diff changeset
   186
		else {
43
hgs
parents: 40
diff changeset
   187
            mCcWidget->hide();
hgs
parents: 40
diff changeset
   188
            mBccWidget->hide();
hgs
parents: 40
diff changeset
   189
			mLayout->removeItem(mCcWidget);
hgs
parents: 40
diff changeset
   190
			mLayout->removeItem(mBccWidget);
40
hgs
parents: 23
diff changeset
   191
		}
44
hgs
parents: 43
diff changeset
   192
        sendDelayedHeaderHeightChanged();
40
hgs
parents: 23
diff changeset
   193
	}
hgs
parents: 23
diff changeset
   194
}
hgs
parents: 23
diff changeset
   195
hgs
parents: 23
diff changeset
   196
/*!
47
hgs
parents: 44
diff changeset
   197
    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
   198
 */
43
hgs
parents: 40
diff changeset
   199
qreal NmEditorHeader::headerHeight() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
{
43
hgs
parents: 40
diff changeset
   201
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   202
hgs
parents: 40
diff changeset
   203
    // get the layout's vertical spacing
hgs
parents: 40
diff changeset
   204
    qreal spacing = 0;
hgs
parents: 40
diff changeset
   205
    HbStyle().parameter("hb-param-margin-gene-middle-vertical", spacing);
hgs
parents: 40
diff changeset
   206
hgs
parents: 40
diff changeset
   207
    // calculate the height
hgs
parents: 40
diff changeset
   208
    qreal height = 0;
hgs
parents: 40
diff changeset
   209
    
hgs
parents: 40
diff changeset
   210
    height += mToField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   211
    height += spacing;
hgs
parents: 40
diff changeset
   212
    
40
hgs
parents: 23
diff changeset
   213
    if (mCcBccFieldVisible) {
43
hgs
parents: 40
diff changeset
   214
        height += mCcField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   215
        height += spacing;
hgs
parents: 40
diff changeset
   216
        
hgs
parents: 40
diff changeset
   217
        height += mBccField->height(); // returns widget's geometry height
hgs
parents: 40
diff changeset
   218
        height += spacing;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
43
hgs
parents: 40
diff changeset
   221
    height += mSubjectWidget->geometry().height();
hgs
parents: 40
diff changeset
   222
    height += spacing;
hgs
parents: 40
diff changeset
   223
hgs
parents: 40
diff changeset
   224
    if (mAttachmentList->listWidget().isVisible()) {
hgs
parents: 40
diff changeset
   225
        height += mAttachmentList->listWidget().geometry().height();
hgs
parents: 40
diff changeset
   226
        height += spacing;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
43
hgs
parents: 40
diff changeset
   229
    return height;
40
hgs
parents: 23
diff changeset
   230
}
hgs
parents: 23
diff changeset
   231
hgs
parents: 23
diff changeset
   232
/*!
44
hgs
parents: 43
diff changeset
   233
    This is called when the contents of some of the header widgets have been changed. When the
hgs
parents: 43
diff changeset
   234
    contents change the widget's actual size may also change. The header area height is needed to
hgs
parents: 43
diff changeset
   235
    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
   236
    the Orbit FW adjust the heights eg. if the subject and recipient fields are expanded by the FW.
hgs
parents: 43
diff changeset
   237
    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
   238
    information.
40
hgs
parents: 23
diff changeset
   239
 */
43
hgs
parents: 40
diff changeset
   240
void NmEditorHeader::sendDelayedHeaderHeightChanged()
40
hgs
parents: 23
diff changeset
   241
{
43
hgs
parents: 40
diff changeset
   242
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   243
	QTimer::singleShot(NmLayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged()));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
}
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
/*!
44
hgs
parents: 43
diff changeset
   247
    Send a signal that the header area height has been changed if necessary. This is needed for the
hgs
parents: 43
diff changeset
   248
    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
   249
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
void NmEditorHeader::sendHeaderHeightChanged()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
{
43
hgs
parents: 40
diff changeset
   252
    qreal hHeight = headerHeight();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
    if (mHeaderHeight != hHeight) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
        mHeaderHeight = hHeight;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
        emit headerHeightChanged(mHeaderHeight);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
}
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
/*!
51
hgs
parents: 48
diff changeset
   260
    Because header filds have fixed size policy. This function must be called to set
hgs
parents: 48
diff changeset
   261
    new width for every header field when orintation has been changed.
hgs
parents: 48
diff changeset
   262
 */
hgs
parents: 48
diff changeset
   263
void NmEditorHeader::adjustHeaderWidth()
hgs
parents: 48
diff changeset
   264
{
hgs
parents: 48
diff changeset
   265
    NM_FUNCTION;
hgs
parents: 48
diff changeset
   266
    
hgs
parents: 48
diff changeset
   267
    int newWidth = mApplication.screenSize().width();
hgs
parents: 48
diff changeset
   268
    mToWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   269
    mCcWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   270
    mBccWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   271
    mSubjectWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   272
    mAttachmentListWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   273
    mSubjectWidget->setPreferredWidth(newWidth);
hgs
parents: 48
diff changeset
   274
}
hgs
parents: 48
diff changeset
   275
hgs
parents: 48
diff changeset
   276
/*!
40
hgs
parents: 23
diff changeset
   277
    Return pointer to to edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
 */
40
hgs
parents: 23
diff changeset
   279
NmRecipientLineEdit* NmEditorHeader::toEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
{
43
hgs
parents: 40
diff changeset
   281
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   282
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
    return mToField->editor();
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
/*!
40
hgs
parents: 23
diff changeset
   287
    Return pointer to cc edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
 */
40
hgs
parents: 23
diff changeset
   289
NmRecipientLineEdit* NmEditorHeader::ccEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
{
43
hgs
parents: 40
diff changeset
   291
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   292
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
    return mCcField->editor();
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
/*!
40
hgs
parents: 23
diff changeset
   297
    Return pointer to bcc edit
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
 */
40
hgs
parents: 23
diff changeset
   299
NmRecipientLineEdit* NmEditorHeader::bccEdit() const
18
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
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    return mBccField->editor();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
}
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
    Return pointer to subject field
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
 */
40
hgs
parents: 23
diff changeset
   309
NmHtmlLineEdit* NmEditorHeader::subjectEdit() const
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
{
43
hgs
parents: 40
diff changeset
   311
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   312
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    return mSubjectEdit;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
}
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
    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
   318
    the state is changed.
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
void NmEditorHeader::editorContentChanged()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
{
43
hgs
parents: 40
diff changeset
   322
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   323
    
47
hgs
parents: 44
diff changeset
   324
    bool recipientsFieldsEmpty(true);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    if (mToField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
        recipientsFieldsEmpty = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
    else if (mCcField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
        recipientsFieldsEmpty = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
    else if (mBccField->text().length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
        recipientsFieldsEmpty = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
    if (mRecipientFieldsEmpty != recipientsFieldsEmpty) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
        mRecipientFieldsEmpty = recipientsFieldsEmpty;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
        emit recipientFieldsHaveContent(!mRecipientFieldsEmpty);
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
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
    Sets the icon for priority
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
void NmEditorHeader::setPriority(NmMessagePriority priority)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
{
43
hgs
parents: 40
diff changeset
   345
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   346
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
    switch (priority) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
    case NmMessagePriorityHigh:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
        setPriority(NmActionResponseCommandPriorityHigh);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
    case NmMessagePriorityLow:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
        setPriority(NmActionResponseCommandPriorityLow);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
    default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
        setPriority(NmActionResponseCommandNone);
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
    }
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
    Sets the icon for priority
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
void NmEditorHeader::setPriority(NmActionResponseCommand prio)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
{
43
hgs
parents: 40
diff changeset
   365
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   366
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
    switch(prio) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    case NmActionResponseCommandPriorityHigh:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
        if (!mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
            mIconVisible = true;
43
hgs
parents: 40
diff changeset
   371
            // icon widget is just after the subject line edit (see docml)
hgs
parents: 40
diff changeset
   372
            mSubjectLayout->insertItem(2, mPriorityIcon);
hgs
parents: 40
diff changeset
   373
            mPriorityIcon->show();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
        }
43
hgs
parents: 40
diff changeset
   375
        mPriorityIcon->setIcon(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
            NmIcons::getIcon(NmIcons::NmIconPriorityHigh));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
    case NmActionResponseCommandPriorityLow:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
        if (!mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
            mIconVisible = true;
43
hgs
parents: 40
diff changeset
   381
            // icon widget is just after the subject line edit (see docml)
hgs
parents: 40
diff changeset
   382
            mSubjectLayout->insertItem(2, mPriorityIcon);
hgs
parents: 40
diff changeset
   383
            mPriorityIcon->show();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
        }
43
hgs
parents: 40
diff changeset
   385
        mPriorityIcon->setIcon(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
            NmIcons::getIcon(NmIcons::NmIconPriorityLow));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
    default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
        if (mIconVisible) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
            mIconVisible = false;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
            HbIcon emptyIcon;
43
hgs
parents: 40
diff changeset
   392
            mPriorityIcon->setIcon(emptyIcon);
hgs
parents: 40
diff changeset
   393
            mSubjectLayout->removeItem(mPriorityIcon);
hgs
parents: 40
diff changeset
   394
            mPriorityIcon->hide();
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
        break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
    }
44
hgs
parents: 43
diff changeset
   398
    sendDelayedHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
}
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
   Adds an attachment to attachment list for mail.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
void NmEditorHeader::addAttachment(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
    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
   406
{
43
hgs
parents: 40
diff changeset
   407
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   408
    
56
hgs
parents: 51
diff changeset
   409
    mAttachmentList->insertAttachment(fileName, fileSize, nmid);
hgs
parents: 51
diff changeset
   410
    
43
hgs
parents: 40
diff changeset
   411
    if (!mAttachmentList->listWidget().isVisible()) {
hgs
parents: 40
diff changeset
   412
        mAttachmentList->listWidget().show();
hgs
parents: 40
diff changeset
   413
    }
51
hgs
parents: 48
diff changeset
   414
47
hgs
parents: 44
diff changeset
   415
    sendHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   419
   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
   420
   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
   421
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
void NmEditorHeader::removeAttachment(const QString &fileName)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
{
43
hgs
parents: 40
diff changeset
   424
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   425
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
    mAttachmentList->removeAttachment(fileName);
43
hgs
parents: 40
diff changeset
   427
    if (mAttachmentList->count() == 0) {
hgs
parents: 40
diff changeset
   428
        mAttachmentList->listWidget().hide();
hgs
parents: 40
diff changeset
   429
        mLayout->removeItem(&mAttachmentList->listWidget());
hgs
parents: 40
diff changeset
   430
    }
44
hgs
parents: 43
diff changeset
   431
    sendDelayedHeaderHeightChanged();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   435
   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
   436
   attachment has been selected for remove.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   437
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   438
void NmEditorHeader::removeAttachment(const NmId &nmid)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   439
{
43
hgs
parents: 40
diff changeset
   440
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   441
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   442
    mAttachmentList->removeAttachment(nmid);
44
hgs
parents: 43
diff changeset
   443
    if (mAttachmentList->count() == 0) {
hgs
parents: 43
diff changeset
   444
        mAttachmentList->listWidget().hide();
hgs
parents: 43
diff changeset
   445
        mLayout->removeItem(&mAttachmentList->listWidget());
hgs
parents: 43
diff changeset
   446
    }
hgs
parents: 43
diff changeset
   447
    sendDelayedHeaderHeightChanged();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   448
}
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
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    This function set messagePartId and fileSize for attachment.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
void NmEditorHeader::setAttachmentParameters(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    const QString &fileName,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    const NmId &msgPartId,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
    const QString &fileSize,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
    int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
{
43
hgs
parents: 40
diff changeset
   459
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   460
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
    if (result == NmNoError) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
        // 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
   463
        mAttachmentList->setAttachmentPartId(fileName, msgPartId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
        mAttachmentList->setAttachmentSize(msgPartId, fileSize);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
    }
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
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   469
   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
   470
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   471
void NmEditorHeader::attachmentActivated(int arrayIndex)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   472
{
43
hgs
parents: 40
diff changeset
   473
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   474
44
hgs
parents: 43
diff changeset
   475
    emit attachmentShortPressed(mAttachmentList->nmIdByIndex(arrayIndex));    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   476
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   477
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   478
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
   Slot attachment selected from attachment list by longtap.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
 */
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   481
void NmEditorHeader::attachmentLongPressed(int arrayIndex, QPointF point)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
{
43
hgs
parents: 40
diff changeset
   483
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   484
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
    // Remove selected attachment
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   486
    emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
}
51
hgs
parents: 48
diff changeset
   488
hgs
parents: 48
diff changeset
   489
/*!
hgs
parents: 48
diff changeset
   490
    This slot is called when scroll position has been changed.
hgs
parents: 48
diff changeset
   491
    Function set new positions for header fields so that header stays visible
hgs
parents: 48
diff changeset
   492
    when body is scrolled horizontally.
hgs
parents: 48
diff changeset
   493
 */
hgs
parents: 48
diff changeset
   494
void NmEditorHeader::repositHeader(const QPointF &scrollPosition)
hgs
parents: 48
diff changeset
   495
{
hgs
parents: 48
diff changeset
   496
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    
51
hgs
parents: 48
diff changeset
   498
    QTransform tr;
hgs
parents: 48
diff changeset
   499
    tr.translate(scrollPosition.x(),0);
hgs
parents: 48
diff changeset
   500
    mToWidget->setTransform(tr);
hgs
parents: 48
diff changeset
   501
    mCcWidget->setTransform(tr);
hgs
parents: 48
diff changeset
   502
    mBccWidget->setTransform(tr);
hgs
parents: 48
diff changeset
   503
    mSubjectWidget->setTransform(tr);
hgs
parents: 48
diff changeset
   504
    mAttachmentListWidget->setTransform(tr);
hgs
parents: 48
diff changeset
   505
}
hgs
parents: 48
diff changeset
   506