|
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 #include <QGraphicsLinearLayout> |
|
18 |
|
19 #include <hbapplication.h> |
|
20 #include <hbmenu.h> |
|
21 #include <hbicon.h> |
|
22 #include <hblistwidget.h> |
|
23 #include <hblistwidgetitem.h> |
|
24 |
|
25 #include "cbsuitopicview.h" |
|
26 #include "cbsuiviewmanager.h" |
|
27 #include "rcbsui.h" |
|
28 #include "cbslog.h" |
|
29 #include "cbsuiconstants.h" |
|
30 |
|
31 const char *T_TITLE = "listWidget2"; |
|
32 const char *T_PREVIOUS= "action"; |
|
33 const char *T_BACK= "action_2"; |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ================================================== |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // CbsUiTopicView::CbsUiTopicView |
|
39 // ---------------------------------------------------------------------------- |
|
40 CbsUiTopicView::CbsUiTopicView() |
|
41 : HbView(), |
|
42 mServer(NULL), |
|
43 mViewManager(NULL), |
|
44 mTopic(NULL), |
|
45 mCurrentTopicNumber(NULL) |
|
46 { |
|
47 LOG(NORMAL,"CBSUI: CbsUiTopicView::CbsUiTopicView IN"); |
|
48 |
|
49 LOG(NORMAL,"CBSUI: CbsUiTopicView::CbsUiTopicView OUT"); |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // CbsUiTopicView::~CbsUiTopicView |
|
54 // ---------------------------------------------------------------------------- |
|
55 CbsUiTopicView::~CbsUiTopicView() |
|
56 { |
|
57 LOG(NORMAL,"CBSUI: CbsUiTopicView::~CbsUiTopicView IN"); |
|
58 LOG(NORMAL,"CBSUI: CbsUiTopicView::~CbsUiTopicView OUT"); |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // CbsUiTopicView::init |
|
63 // ---------------------------------------------------------------------------- |
|
64 void CbsUiTopicView::init(MCbs &server, CbsUiViewManager &viewManager) |
|
65 { |
|
66 LOG(NORMAL,"CBSUI: CbsUiTopicView::init IN"); |
|
67 mViewManager = &viewManager; |
|
68 mServer = &server; |
|
69 createComponents(); |
|
70 LOG(NORMAL,"CBSUI: CbsUiTopicView::init OUT"); |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CbsUiTopicView::TopicListChangedL |
|
75 // ---------------------------------------------------------------------------- |
|
76 void CbsUiTopicView::TopicListChangedL(TCbsTopicListEvent /*aEvent*/, |
|
77 TCbsTopicNumber /*aTopicNumber*/) |
|
78 { |
|
79 LOG(NORMAL,"CBSUI: CbsUiTopicView::TopicListChangedL IN"); |
|
80 /*if (mTopic && |
|
81 mCurrentTopicNumber == aTopicNumber && |
|
82 ECbsTopicReceivedNewMessage == aEvent) { |
|
83 reloadMessages(aTopicNumber); |
|
84 } */ |
|
85 LOG(NORMAL,"CBSUI: CbsUiTopicView::TopicListChangedL OUT"); |
|
86 } |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // CbsUiTopicView::createComponents |
|
90 // ---------------------------------------------------------------------------- |
|
91 void CbsUiTopicView::createComponents() |
|
92 { |
|
93 LOG(NORMAL,"CBSUI: CbsUiTopicView::createComponents IN"); |
|
94 |
|
95 mTopic = qobject_cast<HbListWidget *>( |
|
96 mViewManager->xmlLoader()->findWidget(T_TITLE)); |
|
97 LOG2(NORMAL,"CBSUI: CbsUiTopicView::createComponents mTopic=%d", mTopic); |
|
98 |
|
99 // Previous Action |
|
100 mPrevious = qobject_cast<HbAction *>( |
|
101 mViewManager->xmlLoader()->findObject(T_PREVIOUS)); |
|
102 |
|
103 if (!mPrevious) { |
|
104 LOG(NORMAL,"CBSUI: CbsUiTopicListView::createComponents\ |
|
105 mPrevious faild"); |
|
106 } |
|
107 |
|
108 // Back Action |
|
109 mBack = qobject_cast<HbAction *>( |
|
110 mViewManager->xmlLoader()->findObject(T_BACK)); |
|
111 |
|
112 if (!mBack) { |
|
113 LOG(NORMAL,"CBSUI: CbsUiTopicListView::createComponents\ |
|
114 mBack faild"); |
|
115 } else { |
|
116 connect(mBack, SIGNAL(triggered(bool)), mViewManager, SLOT(activateMainView())); |
|
117 LOG(NORMAL,"CBSUI: CbsUiTopicListView::createComponents\ |
|
118 mBack successfully"); |
|
119 } |
|
120 |
|
121 LOG(NORMAL,"CBSUI: CbsUiTopicView::createComponents OUT"); |
|
122 } |
|
123 |
|
124 // ---------------------------------------------------------------------------- |
|
125 // CbsUiTopicView::reloadMessages |
|
126 // ---------------------------------------------------------------------------- |
|
127 void CbsUiTopicView::reloadMessages(TCbsTopicNumber topicNumber) |
|
128 { |
|
129 LOG(NORMAL,"CBSUI: CbsUiTopicView::reloadMessages IN"); |
|
130 mCurrentTopicNumber = topicNumber; |
|
131 // Update topic details |
|
132 HbListWidgetItem* listItem = new HbListWidgetItem(); |
|
133 TCbsTopic topic; |
|
134 |
|
135 mServer->GetTopic(mCurrentTopicNumber, topic); |
|
136 |
|
137 // Clear first |
|
138 mTopic->clear(); |
|
139 QString name = QString::fromUtf16(topic.iName.Ptr(), topic.iName.Length()); |
|
140 QString numberAndName = QVariant(topic.iNumber).toString(); |
|
141 // instert zeros to topic number in case 2 or 1 digit topic number. |
|
142 switch (numberAndName.length()) { |
|
143 case 1: |
|
144 { |
|
145 numberAndName.insert(0, "0"); |
|
146 numberAndName.insert(0, "0"); |
|
147 break; |
|
148 } |
|
149 case 2: |
|
150 { |
|
151 numberAndName.insert(0, "0"); |
|
152 break; |
|
153 } |
|
154 default:{} |
|
155 // do nothing |
|
156 } |
|
157 |
|
158 listItem->setText(numberAndName); |
|
159 //updateStatusIcon(*listItem, topic); |
|
160 mTopic->addItem(listItem); |
|
161 listItem = NULL; |
|
162 LOG(NORMAL,"CBSUI: CbsUiTopicView::reloadMessages OUT"); |
|
163 } |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CbsUiTopicView::addMessage |
|
167 // ---------------------------------------------------------------------------- |
|
168 void CbsUiTopicView::addMessage(const TCbsMessage& /*message*/, |
|
169 const QString& /*msgName*/) |
|
170 { |
|
171 LOG(NORMAL,"CBSUI: CbsUiTopicView::addMessage IN"); |
|
172 LOG(NORMAL,"CBSUI: CbsUiTopicView::addMessage OUT"); |
|
173 } |
|
174 |
|
175 // End of file |