|
1 /* |
|
2 * Copyright (c) 2010 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 #include <QDebug> |
|
19 #include <QGraphicsLinearLayout> |
|
20 #include <HbTextItem> |
|
21 |
|
22 #include "hstitleresolver.h" |
|
23 #include "hsdeviceinfolistener.h" |
|
24 #include <QDebug> |
|
25 |
|
26 namespace |
|
27 { |
|
28 //Offline text in home screen view title |
|
29 const char hsLocTextId_Title_Offline[] = "txt_homescreen_title_offline"; |
|
30 |
|
31 //Text in home screen view title, when device is out of network coverage or no SIM card present |
|
32 const char hsLocTextId_Title_NoService[] = "txt_homescreen_title_no_service"; |
|
33 } |
|
34 |
|
35 |
|
36 /*! |
|
37 \class HsTitleResolver |
|
38 \ingroup group_hsutils |
|
39 \brief |
|
40 */ |
|
41 |
|
42 /*! |
|
43 |
|
44 */ |
|
45 HsTitleResolver::HsTitleResolver(QObject *parent) |
|
46 : QObject(parent), |
|
47 mCurrentStatus(HsDeviceInfoListener::NoService) |
|
48 { |
|
49 mDeviceInfoListener = new HsDeviceInfoListener(this); |
|
50 mOperatorName = mDeviceInfoListener->operatorName(); |
|
51 mOfflineText = hbTrId(hsLocTextId_Title_Offline); |
|
52 mNoServiceText = hbTrId(hsLocTextId_Title_NoService); |
|
53 |
|
54 connect(mDeviceInfoListener, SIGNAL(networkNameChanged(QString)), SLOT(onNetworkNameChanged(QString))); |
|
55 connect(mDeviceInfoListener, SIGNAL(statusChanged(HsDeviceInfoListener::HsDeviceInfoStatus)), SLOT(onStatusChanged(HsDeviceInfoListener::HsDeviceInfoStatus))); |
|
56 mCurrentStatus = mDeviceInfoListener->status(); |
|
57 } |
|
58 |
|
59 /*! |
|
60 |
|
61 */ |
|
62 HsTitleResolver::~HsTitleResolver() |
|
63 { |
|
64 } |
|
65 |
|
66 /*! |
|
67 |
|
68 */ |
|
69 QString HsTitleResolver::title() |
|
70 { |
|
71 QString titleText; |
|
72 switch (mCurrentStatus) { |
|
73 case HsDeviceInfoListener::NoService: |
|
74 titleText = mNoServiceText; |
|
75 break; |
|
76 case HsDeviceInfoListener::OfflineProfile: |
|
77 titleText = mOfflineText; |
|
78 break; |
|
79 default: |
|
80 if(mOperatorName.isEmpty()) { |
|
81 //Sometimes devicelistener has not get operatorNameChanged signal when |
|
82 //profile is changed from Offline to another which has active connections. |
|
83 mOperatorName = mDeviceInfoListener->operatorName(); |
|
84 } |
|
85 titleText = mOperatorName; |
|
86 break; |
|
87 }; |
|
88 qDebug() << "HsTitleResolver::title() - " << titleText; |
|
89 return titleText; |
|
90 } |
|
91 |
|
92 /*! |
|
93 |
|
94 */ |
|
95 void HsTitleResolver::onNetworkNameChanged(const QString& name) |
|
96 { |
|
97 qDebug() << "HsTitleResolver::onNetworkNameChanged() - Entry"; |
|
98 if (mOperatorName != name && (mCurrentStatus == HsDeviceInfoListener::ServiceAvailable)) { |
|
99 qDebug() << "HsTitleResolver::onNetworkNameChanged() - Emitting: " << name; |
|
100 mOperatorName = name; |
|
101 emit titleChanged(name); |
|
102 } |
|
103 qDebug() << "HsTitleResolver::onNetworkNameChanged() - Exit"; |
|
104 } |
|
105 |
|
106 /*! |
|
107 |
|
108 */ |
|
109 void HsTitleResolver::onStatusChanged(HsDeviceInfoListener::HsDeviceInfoStatus status) |
|
110 { |
|
111 qDebug() << "HsTitleResolver::onStatusChanged() - Entry"; |
|
112 if (mCurrentStatus != status) { |
|
113 mCurrentStatus = status; |
|
114 qDebug() << "HsTitleResolver::onStatusChanged() - Emitting: " << title(); |
|
115 emit titleChanged(title()); |
|
116 } |
|
117 qDebug() << "HsTitleResolver::onStatusChanged() - Exit"; |
|
118 } |
|
119 |