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: This widget displays subject,timestamp & priority info
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "univiewerdetailswidget.h"
|
|
19 |
|
|
20 |
// SYSTEM INCLUDES
|
|
21 |
#include <HbTextItem>
|
|
22 |
#include <HbIconItem>
|
|
23 |
#include <QDateTime>
|
|
24 |
|
|
25 |
// USER INCLUDES
|
|
26 |
#include "convergedmessage.h"
|
|
27 |
#include "debugtraces.h"
|
|
28 |
|
|
29 |
// LOCALIZATION
|
|
30 |
#define LOC_MESSAGE_RESEND hbTrId("txt_common_menu_resend_message")
|
|
31 |
|
|
32 |
// LOCAL CONSTANTS
|
|
33 |
const QString DATE_TIME_FORMAT("dd/MM/yy hh:mm ap"); //Date format.
|
|
34 |
const QString TIME_FORMAT("hh:mm ap");
|
|
35 |
|
|
36 |
const QString MSG_HIGH_PRIORITY_ICON("qtg_small_priority_high");
|
|
37 |
const QString MSG_LOW_PRIORITY_ICON("qtg_small_priority_low");
|
|
38 |
|
|
39 |
//---------------------------------------------------------------
|
|
40 |
// UniViewerDetailsWidget::UniViewerDetailsWidget
|
|
41 |
// @see header file
|
|
42 |
//---------------------------------------------------------------
|
|
43 |
UniViewerDetailsWidget::UniViewerDetailsWidget(QGraphicsItem *parent) :
|
|
44 |
HbWidget(parent), mSubjectLabel(0), mPriorityIcon(0)
|
|
45 |
{
|
|
46 |
// Permanent items & will not be removed
|
|
47 |
mTime = new HbTextItem(this);
|
|
48 |
HbStyle::setItemName(mTime, "timeLabel");
|
|
49 |
}
|
|
50 |
|
|
51 |
//---------------------------------------------------------------
|
|
52 |
// UniViewerDetailsWidget::~UniViewerDetailsWidget
|
|
53 |
// @see header file
|
|
54 |
//---------------------------------------------------------------
|
|
55 |
UniViewerDetailsWidget::~UniViewerDetailsWidget()
|
|
56 |
{
|
|
57 |
}
|
|
58 |
|
|
59 |
//---------------------------------------------------------------
|
|
60 |
//UniViewerDetailsWidget :: setSubject
|
|
61 |
// @see header file
|
|
62 |
//---------------------------------------------------------------
|
|
63 |
void UniViewerDetailsWidget::setSubject(const QString &subject)
|
|
64 |
{
|
|
65 |
if (!mSubjectLabel)
|
|
66 |
{
|
|
67 |
mSubjectLabel = new HbTextItem(this);
|
|
68 |
HbStyle::setItemName(mSubjectLabel, "subjectLabel");
|
|
69 |
mSubjectLabel->setTextWrapping(Hb::TextWrapAnywhere);
|
|
70 |
}
|
|
71 |
mSubjectLabel->setText(subject);
|
|
72 |
this->repolish();
|
|
73 |
}
|
|
74 |
|
|
75 |
//---------------------------------------------------------------
|
|
76 |
//UniViewerDetailsWidget :: setTimeStamp
|
|
77 |
// @see header file
|
|
78 |
//---------------------------------------------------------------
|
|
79 |
void UniViewerDetailsWidget::setTimeStamp(const QDateTime &aTimeStamp, const int &aSendingState)
|
|
80 |
{
|
|
81 |
|
|
82 |
if (aSendingState == ConvergedMessage::Resend) {
|
|
83 |
mTime->setText(LOC_MESSAGE_RESEND + aTimeStamp.toString(TIME_FORMAT));
|
|
84 |
}
|
|
85 |
else {
|
|
86 |
mTime->setText(aTimeStamp.toString(DATE_TIME_FORMAT));
|
|
87 |
}
|
|
88 |
}
|
|
89 |
|
|
90 |
//---------------------------------------------------------------
|
|
91 |
// UniViewerDetailsWidget::setPriorityIcon
|
|
92 |
// @see header file
|
|
93 |
//---------------------------------------------------------------
|
|
94 |
void UniViewerDetailsWidget::setPriorityIcon(int priority)
|
|
95 |
{
|
|
96 |
if (priority)
|
|
97 |
{
|
|
98 |
if (!mPriorityIcon)
|
|
99 |
{
|
|
100 |
mPriorityIcon = new HbIconItem(this);
|
|
101 |
HbStyle::setItemName(mPriorityIcon, "priorityIcon");
|
|
102 |
}
|
|
103 |
if (ConvergedMessage::Low == priority)
|
|
104 |
{
|
|
105 |
mPriorityIcon->setIcon(HbIcon(MSG_LOW_PRIORITY_ICON));
|
|
106 |
}
|
|
107 |
else if (ConvergedMessage::High == priority)
|
|
108 |
{
|
|
109 |
mPriorityIcon->setIcon(HbIcon(MSG_HIGH_PRIORITY_ICON));
|
|
110 |
}
|
|
111 |
this->repolish();
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
//---------------------------------------------------------------
|
|
116 |
//UniViewerDetailsWidget :: clearContent
|
|
117 |
// @see header file
|
|
118 |
//---------------------------------------------------------------
|
|
119 |
void UniViewerDetailsWidget::clearContent()
|
|
120 |
{
|
|
121 |
//Delete the temporary items(subject & priority) &
|
|
122 |
//content on the permanent item
|
|
123 |
|
|
124 |
if (mSubjectLabel)
|
|
125 |
{
|
|
126 |
mSubjectLabel->setParent(NULL);
|
|
127 |
delete mSubjectLabel;
|
|
128 |
mSubjectLabel = NULL;
|
|
129 |
}
|
|
130 |
|
|
131 |
if (mPriorityIcon)
|
|
132 |
{
|
|
133 |
mPriorityIcon->setParent(NULL);
|
|
134 |
delete mPriorityIcon;
|
|
135 |
mPriorityIcon = NULL;
|
|
136 |
}
|
|
137 |
|
|
138 |
mTime->setText(QString());
|
|
139 |
}
|
|
140 |
|
|
141 |
// EOF
|