author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 09:45:25 +0300 | |
changeset 52 | 12db4185673b |
parent 31 | ebfee66fde93 |
permissions | -rw-r--r-- |
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> |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
23 |
#include <HbExtendedLocale> |
31 | 24 |
#include <QDateTime> |
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
25 |
#include <QStringBuilder> |
31 | 26 |
|
27 |
// USER INCLUDES |
|
28 |
#include "convergedmessage.h" |
|
29 |
#include "debugtraces.h" |
|
30 |
||
31 |
// LOCALIZATION |
|
32 |
#define LOC_MESSAGE_RESEND hbTrId("txt_common_menu_resend_message") |
|
33 |
||
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
34 |
// @see hbi18ndef.h |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
35 |
static const char DATE_FORMAT[] = r_qtn_date_usual_with_zero; |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
36 |
static const char TIME_FORMAT[] = r_qtn_time_usual_with_zero; |
31 | 37 |
|
38 |
const QString MSG_HIGH_PRIORITY_ICON("qtg_small_priority_high"); |
|
39 |
const QString MSG_LOW_PRIORITY_ICON("qtg_small_priority_low"); |
|
40 |
||
41 |
//--------------------------------------------------------------- |
|
42 |
// UniViewerDetailsWidget::UniViewerDetailsWidget |
|
43 |
// @see header file |
|
44 |
//--------------------------------------------------------------- |
|
45 |
UniViewerDetailsWidget::UniViewerDetailsWidget(QGraphicsItem *parent) : |
|
46 |
HbWidget(parent), mSubjectLabel(0), mPriorityIcon(0) |
|
47 |
{ |
|
48 |
// Permanent items & will not be removed |
|
49 |
mTime = new HbTextItem(this); |
|
50 |
HbStyle::setItemName(mTime, "timeLabel"); |
|
51 |
} |
|
52 |
||
53 |
//--------------------------------------------------------------- |
|
54 |
// UniViewerDetailsWidget::~UniViewerDetailsWidget |
|
55 |
// @see header file |
|
56 |
//--------------------------------------------------------------- |
|
57 |
UniViewerDetailsWidget::~UniViewerDetailsWidget() |
|
58 |
{ |
|
59 |
} |
|
60 |
||
61 |
//--------------------------------------------------------------- |
|
62 |
//UniViewerDetailsWidget :: setSubject |
|
63 |
// @see header file |
|
64 |
//--------------------------------------------------------------- |
|
65 |
void UniViewerDetailsWidget::setSubject(const QString &subject) |
|
66 |
{ |
|
67 |
if (!mSubjectLabel) |
|
68 |
{ |
|
69 |
mSubjectLabel = new HbTextItem(this); |
|
70 |
HbStyle::setItemName(mSubjectLabel, "subjectLabel"); |
|
71 |
mSubjectLabel->setTextWrapping(Hb::TextWrapAnywhere); |
|
72 |
} |
|
73 |
mSubjectLabel->setText(subject); |
|
74 |
this->repolish(); |
|
75 |
} |
|
76 |
||
77 |
//--------------------------------------------------------------- |
|
78 |
//UniViewerDetailsWidget :: setTimeStamp |
|
79 |
// @see header file |
|
80 |
//--------------------------------------------------------------- |
|
81 |
void UniViewerDetailsWidget::setTimeStamp(const QDateTime &aTimeStamp, const int &aSendingState) |
|
82 |
{ |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
83 |
HbExtendedLocale locale = HbExtendedLocale::system(); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
84 |
QString date = locale.format(aTimeStamp.date(), DATE_FORMAT); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
85 |
QString time = locale.format(aTimeStamp.time(), TIME_FORMAT); |
31 | 86 |
|
87 |
if (aSendingState == ConvergedMessage::Resend) { |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
88 |
mTime->setText(LOC_MESSAGE_RESEND % time); |
31 | 89 |
} |
90 |
else { |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
91 |
mTime->setText(date % QChar(' ') % time); |
31 | 92 |
} |
93 |
} |
|
94 |
||
95 |
//--------------------------------------------------------------- |
|
96 |
// UniViewerDetailsWidget::setPriorityIcon |
|
97 |
// @see header file |
|
98 |
//--------------------------------------------------------------- |
|
99 |
void UniViewerDetailsWidget::setPriorityIcon(int priority) |
|
100 |
{ |
|
101 |
if (priority) |
|
102 |
{ |
|
103 |
if (!mPriorityIcon) |
|
104 |
{ |
|
105 |
mPriorityIcon = new HbIconItem(this); |
|
106 |
HbStyle::setItemName(mPriorityIcon, "priorityIcon"); |
|
107 |
} |
|
108 |
if (ConvergedMessage::Low == priority) |
|
109 |
{ |
|
110 |
mPriorityIcon->setIcon(HbIcon(MSG_LOW_PRIORITY_ICON)); |
|
111 |
} |
|
112 |
else if (ConvergedMessage::High == priority) |
|
113 |
{ |
|
114 |
mPriorityIcon->setIcon(HbIcon(MSG_HIGH_PRIORITY_ICON)); |
|
115 |
} |
|
116 |
this->repolish(); |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
//--------------------------------------------------------------- |
|
121 |
//UniViewerDetailsWidget :: clearContent |
|
122 |
// @see header file |
|
123 |
//--------------------------------------------------------------- |
|
124 |
void UniViewerDetailsWidget::clearContent() |
|
125 |
{ |
|
126 |
//Delete the temporary items(subject & priority) & |
|
127 |
//content on the permanent item |
|
128 |
||
129 |
if (mSubjectLabel) |
|
130 |
{ |
|
131 |
mSubjectLabel->setParent(NULL); |
|
132 |
delete mSubjectLabel; |
|
133 |
mSubjectLabel = NULL; |
|
134 |
} |
|
135 |
||
136 |
if (mPriorityIcon) |
|
137 |
{ |
|
138 |
mPriorityIcon->setParent(NULL); |
|
139 |
delete mPriorityIcon; |
|
140 |
mPriorityIcon = NULL; |
|
141 |
} |
|
142 |
||
143 |
mTime->setText(QString()); |
|
144 |
} |
|
145 |
||
146 |
// EOF |