31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDES
|
|
19 |
#include "debugtraces.h"
|
|
20 |
#include <HbIconItem>
|
|
21 |
#include <HbNotificationDialog>
|
|
22 |
|
|
23 |
// USER INCLUDES
|
|
24 |
#include "msgunieditorsubject.h"
|
|
25 |
#include "UniEditorGenUtils.h"
|
|
26 |
#include "msgunifiededitorlineedit.h"
|
|
27 |
#include "msgmonitor.h"
|
|
28 |
|
|
29 |
// Localized Constants
|
|
30 |
#define LOC_SUBJECT hbTrId("txt_messaging_formlabel_subject")
|
|
31 |
#define LOC_UNABLE_TO_ADD_CONTENT hbTrId("txt_messaging_dpopinfo_unable_to_add_more_content")
|
|
32 |
|
|
33 |
//priority icon
|
|
34 |
const QString HIGH_PRIORITY("qtg_small_priority_high");
|
|
35 |
const QString LOW_PRIORITY("qtg_small_priority_low");
|
|
36 |
|
|
37 |
//---------------------------------------------------------------
|
|
38 |
// MsgUnifiedEditorSubject::MsgUnifiedEditorSubject
|
|
39 |
// @see header file
|
|
40 |
//---------------------------------------------------------------
|
|
41 |
MsgUnifiedEditorSubject::MsgUnifiedEditorSubject( QGraphicsItem *parent ) :
|
|
42 |
MsgUnifiedEditorBaseWidget(parent),
|
|
43 |
mPriorityIcon(NULL),
|
|
44 |
mPriority(ConvergedMessage::Normal),
|
|
45 |
mGenUtils(0)
|
|
46 |
{
|
|
47 |
mSubjectEdit = new MsgUnifiedEditorLineEdit(LOC_SUBJECT,this);
|
|
48 |
mSubjectEdit->setDefaultBehaviour(true);
|
|
49 |
HbStyle::setItemName(mSubjectEdit,"subjectEdit");
|
|
50 |
mSubjectEdit->setMinRows(1);
|
|
51 |
mSubjectEdit->setMaxRows(10);
|
|
52 |
|
|
53 |
mGenUtils = new UniEditorGenUtils();
|
|
54 |
|
|
55 |
connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)),
|
|
56 |
this, SLOT(onContentsChanged(const QString&)));
|
|
57 |
}
|
|
58 |
|
|
59 |
//---------------------------------------------------------------
|
|
60 |
// MsgUnifiedEditorSubject::~MsgUnifiedEditorSubject
|
|
61 |
// @see header file
|
|
62 |
//---------------------------------------------------------------
|
|
63 |
MsgUnifiedEditorSubject::~MsgUnifiedEditorSubject()
|
|
64 |
{
|
|
65 |
if(mGenUtils)
|
|
66 |
{
|
|
67 |
delete mGenUtils;
|
|
68 |
mGenUtils = NULL;
|
|
69 |
}
|
|
70 |
}
|
|
71 |
|
|
72 |
void MsgUnifiedEditorSubject::setPriority(ConvergedMessage::Priority priority)
|
|
73 |
{
|
|
74 |
mPriority = priority;
|
|
75 |
if(mPriorityIcon)
|
|
76 |
{// Transition from low/high => low/normal/high
|
|
77 |
mPriorityIcon->setParent(NULL);
|
|
78 |
delete mPriorityIcon;
|
|
79 |
mPriorityIcon = NULL;
|
|
80 |
}
|
|
81 |
|
|
82 |
switch(priority)
|
|
83 |
{
|
|
84 |
case ConvergedMessage::High :
|
|
85 |
{
|
|
86 |
mPriorityIcon = new HbIconItem(HIGH_PRIORITY, this);
|
|
87 |
HbStyle::setItemName(mPriorityIcon,"priorityIcon");
|
|
88 |
}
|
|
89 |
break;
|
|
90 |
case ConvergedMessage::Low :
|
|
91 |
{
|
|
92 |
mPriorityIcon = new HbIconItem(LOW_PRIORITY, this);
|
|
93 |
HbStyle::setItemName(mPriorityIcon,"priorityIcon");
|
|
94 |
}
|
|
95 |
break;
|
|
96 |
default:
|
|
97 |
break;
|
|
98 |
}
|
|
99 |
|
|
100 |
emit contentChanged();
|
|
101 |
this->repolish();
|
|
102 |
}
|
|
103 |
|
|
104 |
QString MsgUnifiedEditorSubject::text()
|
|
105 |
{
|
|
106 |
return mSubjectEdit->content();
|
|
107 |
}
|
|
108 |
|
|
109 |
ConvergedMessage::Priority MsgUnifiedEditorSubject::priority()
|
|
110 |
{
|
|
111 |
return mPriority;
|
|
112 |
}
|
|
113 |
|
|
114 |
void MsgUnifiedEditorSubject::onContentsChanged(const QString& text)
|
|
115 |
{
|
|
116 |
// reject any text input if mms size limit is reached
|
|
117 |
int futureSize = subjectSize() +
|
|
118 |
MsgMonitor::containerSize() + MsgMonitor::bodySize();
|
|
119 |
if(futureSize > MsgMonitor::maxMmsSize())
|
|
120 |
{
|
|
121 |
// atomic operation
|
|
122 |
disconnect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)),
|
|
123 |
this, SLOT(onContentsChanged(const QString&)));
|
|
124 |
mSubjectEdit->clearContent();
|
|
125 |
mSubjectEdit->setText(mPrevBuffer);
|
|
126 |
connect(mSubjectEdit, SIGNAL(contentsChanged(const QString&)),
|
|
127 |
this, SLOT(onContentsChanged(const QString&)));
|
|
128 |
HbNotificationDialog::launchDialog(LOC_UNABLE_TO_ADD_CONTENT);
|
|
129 |
return;
|
|
130 |
}
|
|
131 |
|
|
132 |
mPrevBuffer = text;
|
|
133 |
if(!subjectOkInSms())
|
|
134 |
{
|
|
135 |
emit contentChanged();
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
bool MsgUnifiedEditorSubject::subjectOkInSms()
|
|
140 |
{
|
|
141 |
bool result = false;
|
|
142 |
int error;
|
|
143 |
TRAP(error, result = mGenUtils->AcceptEmailAddressesL());
|
|
144 |
return result;
|
|
145 |
}
|
|
146 |
|
|
147 |
int MsgUnifiedEditorSubject::subjectSize()
|
|
148 |
{
|
|
149 |
return mGenUtils->UTF8Size(mSubjectEdit->content());
|
|
150 |
}
|
|
151 |
|
|
152 |
void MsgUnifiedEditorSubject::setText(const QString& text)
|
|
153 |
{
|
|
154 |
mSubjectEdit->setText(text);
|
|
155 |
}
|
|
156 |
|
|
157 |
void MsgUnifiedEditorSubject::setFocus()
|
|
158 |
{
|
|
159 |
mSubjectEdit->setFocus(Qt::MouseFocusReason);
|
|
160 |
}
|
|
161 |
|
|
162 |
//EOF
|