24
|
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 |
#include <QStandardItemModel>
|
|
19 |
#include <QDebug>
|
|
20 |
|
|
21 |
#include <hbmainwindow.h>
|
|
22 |
#include <hbapplication.h>
|
|
23 |
#include <hbaction.h>
|
|
24 |
#include <hbtoolbar.h>
|
|
25 |
#include <hblabel.h>
|
|
26 |
|
|
27 |
#include <hbtreeview.h>
|
|
28 |
#include <hblistview.h>
|
|
29 |
#include <hbsearchpanel.h>
|
|
30 |
#include <hbscrollbar.h>
|
|
31 |
#include <hblineedit.h>
|
|
32 |
#include <hbmenu.h>
|
|
33 |
#include <hbstaticvkbhost.h>
|
|
34 |
|
|
35 |
#include "HelpDataProvider.h"
|
|
36 |
#include "HelpProxyModel.h"
|
|
37 |
|
|
38 |
#include "HelpKeywordView.h"
|
|
39 |
|
|
40 |
|
|
41 |
//////////////////////////////////////////////////////////////////////////////////////////////
|
|
42 |
|
|
43 |
HelpKeywordView::HelpKeywordView() :
|
|
44 |
mListSearch(NULL),
|
|
45 |
mSearchPanel(NULL)
|
|
46 |
{
|
|
47 |
}
|
|
48 |
|
|
49 |
HelpKeywordView::~HelpKeywordView()
|
|
50 |
{
|
|
51 |
}
|
|
52 |
|
|
53 |
|
|
54 |
////////////////////////////////////////////////////////////////////////////////////////////
|
|
55 |
|
|
56 |
void HelpKeywordView::init()
|
|
57 |
{
|
|
58 |
initDocMl();
|
|
59 |
initBackAction();
|
|
60 |
initSearchList();
|
|
61 |
initSearchPanel();
|
|
62 |
initVirtualKeyboard();
|
|
63 |
|
|
64 |
connect(mainWindow(), SIGNAL(viewReady()), this, SLOT(onViewReady()));
|
|
65 |
}
|
|
66 |
|
|
67 |
void HelpKeywordView::initDocMl()
|
|
68 |
{
|
|
69 |
initBaseDocMl();
|
|
70 |
mBuilder.load(QRC_DOCML_KEYWORD);
|
|
71 |
}
|
|
72 |
|
|
73 |
void HelpKeywordView::initBackAction()
|
|
74 |
{
|
|
75 |
mSoftKeyAction = new HbAction(Hb::BackNaviAction);
|
|
76 |
connect(mSoftKeyAction, SIGNAL(triggered()), this, SLOT(onBackAction()));
|
|
77 |
}
|
|
78 |
|
|
79 |
void HelpKeywordView::initSearchList()
|
|
80 |
{
|
|
81 |
mListSearch = mBuilder.findWidget<HbListView*>(DOCML_LIST_SEARCH);
|
|
82 |
mListSearch->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
|
|
83 |
mListSearch->setModel(HelpDataProvider::instance()->getSearchData());
|
|
84 |
connect(mListSearch, SIGNAL(activated(const QModelIndex&)), this, SLOT(onSearchListActivated(const QModelIndex&)));
|
|
85 |
}
|
|
86 |
void HelpKeywordView::initSearchPanel()
|
|
87 |
{
|
|
88 |
mSearchPanel = mBuilder.findWidget<HbSearchPanel*>(DOCML_SEARCH_PANEL);
|
|
89 |
connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(onSearchPanelExitClicked()));
|
|
90 |
connect(mSearchPanel, SIGNAL(criteriaChanged(const QString&)), this, SLOT(onSearchPanelCriteriaChanged(const QString&)));
|
|
91 |
}
|
|
92 |
|
|
93 |
void HelpKeywordView::initVirtualKeyboard()
|
|
94 |
{
|
|
95 |
mVirtualKeyboard = new HbStaticVkbHost(this);
|
|
96 |
connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(onHandleKeypadOpen()));
|
|
97 |
connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(onHandleKeypadClose()));
|
|
98 |
}
|
|
99 |
|
26
|
100 |
HbLabel* HelpKeywordView::label()
|
24
|
101 |
{
|
26
|
102 |
return mBuilder.findWidget<HbLabel*>(DOCML_NO_MATCH_LABEL);
|
24
|
103 |
}
|
|
104 |
|
|
105 |
void HelpKeywordView::loadAllContent()
|
|
106 |
{
|
26
|
107 |
toolBar()->hide();
|
24
|
108 |
mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH);
|
|
109 |
ResetSearchPanel();
|
26
|
110 |
|
24
|
111 |
}
|
|
112 |
|
|
113 |
////////////////////////////////////////////////////////////////////////////////////////////
|
|
114 |
|
|
115 |
void HelpKeywordView::updateVisibleItems(bool visible)
|
|
116 |
{
|
|
117 |
static Hb::SceneItems items = Hb::TitleBarItem | Hb::StatusBarItem;
|
|
118 |
if(visible)
|
|
119 |
{
|
|
120 |
showItems(items);
|
|
121 |
}
|
|
122 |
else
|
|
123 |
{
|
|
124 |
hideItems(items);
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
void HelpKeywordView::ResetSearchPanel()
|
|
129 |
{
|
|
130 |
foreach(QGraphicsItem *obj, mSearchPanel->childItems())
|
|
131 |
{
|
|
132 |
QGraphicsWidget *const widget = static_cast<QGraphicsWidget*>(obj);
|
|
133 |
if(widget != NULL)
|
|
134 |
{
|
|
135 |
HbLineEdit *const lineEdit = qobject_cast<HbLineEdit*>(widget);
|
|
136 |
if(lineEdit != NULL)
|
|
137 |
{
|
|
138 |
lineEdit->setText("");
|
|
139 |
lineEdit->setFocus();
|
|
140 |
break;
|
|
141 |
}
|
|
142 |
}
|
|
143 |
}
|
|
144 |
}
|
|
145 |
|
26
|
146 |
void HelpKeywordView::updateLabelPos()
|
|
147 |
{
|
|
148 |
HbDeviceProfile profile = HbDeviceProfile::profile(mainWindow());
|
|
149 |
qreal unValue = profile.unitValue();
|
|
150 |
if(mainWindow()->orientation() == Qt::Vertical)
|
|
151 |
{
|
|
152 |
if(mVirtualKeyboard->keypadStatus() == HbVkbHost::HbVkbStatusClosed)
|
|
153 |
{
|
|
154 |
label()->setContentsMargins(0,30 * unValue,0,0);
|
|
155 |
}
|
|
156 |
else
|
|
157 |
{
|
|
158 |
label()->setContentsMargins(0,10 * unValue,0,0);
|
|
159 |
}
|
|
160 |
}
|
|
161 |
else
|
|
162 |
{
|
|
163 |
if(mVirtualKeyboard->keypadStatus() == HbVkbHost::HbVkbStatusClosed)
|
|
164 |
{
|
|
165 |
label()->setContentsMargins(0,10 * unValue,0,0);
|
|
166 |
}
|
|
167 |
else
|
|
168 |
{
|
|
169 |
label()->setContentsMargins(0,0,0,0);
|
|
170 |
label()->setAlignment(label()->alignment() | Qt::AlignVCenter);
|
|
171 |
}
|
|
172 |
}
|
|
173 |
}
|
|
174 |
|
24
|
175 |
////////////////////////////////////////////////////////////////////////////////////////////
|
|
176 |
// handle system event
|
|
177 |
|
|
178 |
void HelpKeywordView::onViewReady()
|
|
179 |
{
|
|
180 |
if(isVisible())
|
|
181 |
{
|
|
182 |
setNavigationAction(mSoftKeyAction);
|
|
183 |
}
|
|
184 |
}
|
|
185 |
|
|
186 |
///////////////////////////////////////////////////////////////////////////////////////
|
|
187 |
// handle button back action
|
|
188 |
|
|
189 |
void HelpKeywordView::onBackAction()
|
|
190 |
{
|
|
191 |
emit activateView(HelpViewCategory);
|
|
192 |
}
|
|
193 |
|
|
194 |
|
|
195 |
////////////////////////////////////////////////////////////////////////////////////////////
|
|
196 |
// handle list event
|
|
197 |
|
|
198 |
void HelpKeywordView::onSearchListActivated(const QModelIndex& index)
|
|
199 |
{
|
|
200 |
if(!index.isValid() || // invalid
|
|
201 |
index.child(0,0).isValid()) // this is a node
|
|
202 |
{
|
|
203 |
return;
|
|
204 |
}
|
|
205 |
|
|
206 |
QString uid = mListSearch->model()->data(index, UidRole).toString();
|
|
207 |
QString href = mListSearch->model()->data(index, HrefRole).toString();
|
|
208 |
HelpDataProvider::instance()->setHelpContentUrl(uid, href);
|
|
209 |
emit activateView(HelpViewContents);
|
|
210 |
}
|
|
211 |
|
|
212 |
|
|
213 |
////////////////////////////////////////////////////////////////////////////////////////////
|
|
214 |
// handle search panel event
|
|
215 |
|
|
216 |
void HelpKeywordView::onSearchPanelExitClicked()
|
|
217 |
{
|
|
218 |
if(mListSearch->model()->rowCount() == 0)
|
|
219 |
{
|
|
220 |
mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH_NO_SRHPAL_NO_MATCH);
|
|
221 |
}
|
|
222 |
else
|
|
223 |
{
|
|
224 |
mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH_NO_SRHPAL);
|
|
225 |
}
|
|
226 |
toolBar()->show();
|
|
227 |
}
|
|
228 |
|
|
229 |
void HelpKeywordView::onSearchPanelCriteriaChanged(const QString &criteria)
|
|
230 |
{
|
|
231 |
HelpDataProvider::instance()->getSearchData(criteria);
|
|
232 |
if(mListSearch->model()->rowCount() == 0)
|
|
233 |
{
|
|
234 |
mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH_NO_MATCH);
|
|
235 |
}
|
|
236 |
else
|
|
237 |
{
|
|
238 |
mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH);
|
|
239 |
}
|
|
240 |
|
|
241 |
toolBar()->hide();
|
|
242 |
}
|
|
243 |
|
|
244 |
////////////////////////////////////////////////////////////////////////////////////////////
|
|
245 |
// handle virtual keyboard event
|
|
246 |
|
|
247 |
void HelpKeywordView::onHandleKeypadOpen()
|
|
248 |
{
|
|
249 |
updateVisibleItems(false);
|
|
250 |
qreal heightToSet = mainWindow()->layoutRect().height() - mVirtualKeyboard->keyboardArea().height();
|
|
251 |
this->setMaximumHeight(heightToSet);
|
26
|
252 |
updateLabelPos();
|
24
|
253 |
}
|
|
254 |
|
|
255 |
void HelpKeywordView::onHandleKeypadClose()
|
|
256 |
{
|
|
257 |
updateVisibleItems(true);
|
|
258 |
qreal mainHeight = mainWindow()->layoutRect().height();
|
|
259 |
qreal toolbarHeight = toolBar()->size().height();
|
|
260 |
qreal height = mainHeight - (toolBar()->isVisible() ? toolbarHeight : 0);
|
|
261 |
this->setMaximumHeight(height);
|
26
|
262 |
updateLabelPos();
|
|
263 |
}
|
|
264 |
|
|
265 |
void HelpKeywordView::onOrientationChanged(Qt::Orientation orientation)
|
|
266 |
{
|
|
267 |
HelpBaseView::onOrientationChanged(orientation);
|
|
268 |
updateLabelPos();
|
24
|
269 |
}
|
|
270 |
|
|
271 |
// end of file
|