54 |
56 |
55 //////////////////////////////////////////////////////////////////////////////////////////// |
57 //////////////////////////////////////////////////////////////////////////////////////////// |
56 |
58 |
57 void HelpCategoryView::init() |
59 void HelpCategoryView::init() |
58 { |
60 { |
|
61 initDocMl(); |
59 initBackAction(); |
62 initBackAction(); |
60 initAllList(); |
63 initAllList(); |
61 initSearchList(); |
64 initSearchList(); |
62 initSearchPanel(); |
65 initSearchPanel(); |
63 initToolbar(); |
66 initVirtualKeyboard(); |
|
67 initEmptyLabel(); |
64 |
68 |
65 switchViewMode(ViewModeAll); |
69 switchViewMode(ViewModeAll); |
66 |
70 |
67 connect(mainWindow(), SIGNAL(currentViewChanged(HbView*)), this, SLOT(onCurrentViewChanged(HbView*))); |
71 connect(mainWindow(), SIGNAL(currentViewChanged(HbView*)), this, SLOT(onCurrentViewChanged(HbView*))); |
68 connect(mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(onOrientationChanged(Qt::Orientation))); |
72 } |
|
73 |
|
74 void HelpCategoryView::initDocMl() |
|
75 { |
|
76 // Create widget hierarchy |
|
77 setObjectName( DOCML_VIEW_CATEGORY ); |
|
78 |
|
79 // List existing root elements - this allows us to refer to objects in the XML |
|
80 // which are created outside the document. |
|
81 QObjectList roots; |
|
82 roots.append( this ); |
|
83 |
|
84 mBuilder.setObjectTree(roots); |
|
85 |
|
86 mBuilder.load(QRC_DOCML_CATEGORY); |
69 } |
87 } |
70 |
88 |
71 void HelpCategoryView::initBackAction() |
89 void HelpCategoryView::initBackAction() |
72 { |
90 { |
73 mSoftKeyAction = new HbAction(Hb::BackAction); |
91 mSoftKeyAction = new HbAction(Hb::BackAction); |
74 connect(mSoftKeyAction, SIGNAL(triggered()), this, SLOT(onBackAction())); |
92 connect(mSoftKeyAction, SIGNAL(triggered()), this, SLOT(onBackAction())); |
75 } |
93 } |
76 |
94 |
77 void HelpCategoryView::initAllList() |
95 void HelpCategoryView::initAllList() |
78 { |
96 { |
79 mListAll = HelpUIBuilder::findWidget<HbTreeView*>(DOCML_LIST_CATEGORY_ALL); |
97 mListAll = mBuilder.findWidget<HbTreeView*>(DOCML_LIST_CATEGORY_ALL); |
80 mListAll->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
98 mListAll->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
81 mListAll->setModel(HelpDataProvider::instance()->getCategoryData()); |
99 mListAll->setModel(HelpDataProvider::instance()->getCategoryData()); |
82 connect(mListAll, SIGNAL(activated(const QModelIndex&)), this, SLOT(onAllListActivated(const QModelIndex&))); |
100 connect(mListAll, SIGNAL(activated(const QModelIndex&)), this, SLOT(onAllListActivated(const QModelIndex&))); |
83 } |
101 } |
84 |
102 |
85 void HelpCategoryView::initSearchList() |
103 void HelpCategoryView::initSearchList() |
86 { |
104 { |
87 mListSearch = HelpUIBuilder::findWidget<HbTreeView*>(DOCML_LIST_CATEGORY_SEARCH); |
105 mListSearch = mBuilder.findWidget<HbListView*>(DOCML_LIST_CATEGORY_SEARCH); |
88 mListSearch->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
106 mListSearch->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
89 mListSearch->setModel(HelpDataProvider::instance()->getSearchData()); |
107 mListSearch->setModel(HelpDataProvider::instance()->getSearchData()); |
90 connect(mListSearch, SIGNAL(activated(const QModelIndex&)), this, SLOT(onSearchListActivated(const QModelIndex&))); |
108 connect(mListSearch, SIGNAL(activated(const QModelIndex&)), this, SLOT(onSearchListActivated(const QModelIndex&))); |
91 } |
109 } |
92 void HelpCategoryView::initSearchPanel() |
110 void HelpCategoryView::initSearchPanel() |
93 { |
111 { |
94 mSearchPanel = HelpUIBuilder::findWidget<HbSearchPanel*>(DOCML_SEARCH_PANEL_CATEGORY); |
112 mSearchPanel = mBuilder.findWidget<HbSearchPanel*>(DOCML_SEARCH_PANEL_CATEGORY); |
95 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(onSearchPanelExitClicked())); |
113 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(onSearchPanelExitClicked())); |
96 connect(mSearchPanel, SIGNAL(criteriaChanged(const QString&)), this, SLOT(onSearchPanelCriteriaChanged(const QString&))); |
114 connect(mSearchPanel, SIGNAL(criteriaChanged(const QString&)), this, SLOT(onSearchPanelCriteriaChanged(const QString&))); |
97 } |
115 } |
98 |
116 |
99 void HelpCategoryView::initToolbar() |
117 void HelpCategoryView::initVirtualKeyboard() |
100 { |
118 { |
101 mToolBar = HelpUIBuilder::findWidget<HbToolBar*>(DOCML_TOOLBAR); |
119 mVirtualKeyboard = new HbStaticVkbHost(this); |
102 |
120 connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(onHandleKeypadOpen())); |
103 HbAction* allAction = HelpUIBuilder::findObject<HbAction*>(DOCML_ACTION_ALL); |
121 connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(onHandleKeypadClose())); |
104 HbAction* findAction = HelpUIBuilder::findObject<HbAction*>(DOCML_ACTION_SEARCH); |
122 } |
105 QActionGroup* toolBarActionGroup = new QActionGroup(mToolBar); |
123 |
106 allAction->setActionGroup(toolBarActionGroup); |
124 void HelpCategoryView::initEmptyLabel() |
107 findAction->setActionGroup(toolBarActionGroup); |
125 { |
108 } |
126 HbLabel* label = mBuilder.findWidget<HbLabel*>(DOCML_NO_MATCH_LABEL); |
109 |
127 label->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
|
128 } |
|
129 |
|
130 HbGroupBox* HelpCategoryView::groupBox() |
|
131 { |
|
132 return mBuilder.findWidget<HbGroupBox*>(DOCML_GROUPBOX); |
|
133 } |
110 |
134 |
111 //////////////////////////////////////////////////////////////////////////////////////////// |
135 //////////////////////////////////////////////////////////////////////////////////////////// |
112 |
136 |
113 void HelpCategoryView::switchViewMode(ViewMode viewMode) |
137 void HelpCategoryView::switchViewMode(ViewMode viewMode) |
114 { |
138 { |
115 if(ViewModeNull == viewMode) return; |
139 if(ViewModeNull == viewMode) return; |
116 |
140 |
117 mViewMode = viewMode; |
141 mViewMode = viewMode; |
118 if(ViewModeAll == viewMode) |
142 if(ViewModeAll == viewMode) |
119 { |
143 { |
120 HelpUIBuilder::load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_ALL); |
144 mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_ALL); |
|
145 toolBar()->show(); |
121 } |
146 } |
122 else if(ViewModeSearch == viewMode) |
147 else if(ViewModeSearch == viewMode) |
123 { |
148 { |
124 HelpUIBuilder::load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH); |
149 // mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH); |
125 } |
150 ResetSearchPanel(); |
126 |
151 } |
127 RefreshTitlebarVisibility(); |
152 } |
128 } |
153 |
129 |
154 //////////////////////////////////////////////////////////////////////////////////////////// |
130 |
155 |
131 //////////////////////////////////////////////////////////////////////////////////////////// |
156 void HelpCategoryView::expandCollapseAllList(QStandardItem* item, bool expand) |
132 |
157 { |
133 void HelpCategoryView::RefreshToolbarText(bool isLandscape) |
158 if(item->rowCount() <= 0) |
134 { |
159 { |
135 HbAction* tollbarAction = HelpUIBuilder::findObject<HbAction*>(DOCML_ACTION_ALL); |
160 return; |
136 tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_ALL) : QString()); |
161 } |
137 |
162 mListAll->setExpanded(item->index(),expand); |
138 tollbarAction = HelpUIBuilder::findObject<HbAction*>(DOCML_ACTION_SEARCH); |
163 for(int i = 0; i < item->rowCount(); i++) |
139 tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_FIND) : QString()); |
164 { |
140 |
165 expandCollapseAllList(item->child(i),expand); |
141 tollbarAction = HelpUIBuilder::findObject<HbAction*>(DOCML_ACTION_LINK_NOKIA); |
166 } |
142 tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_LINK_SUPPORT) : QString()); |
167 } |
143 } |
168 |
144 |
169 //////////////////////////////////////////////////////////////////////////////////////////// |
145 void HelpCategoryView::RefreshTitlebarVisibility() |
170 |
146 { |
171 void HelpCategoryView::updateVisibleItems(bool visible) |
147 setTitleBarVisible(!(mSearchPanel->isVisible())); |
172 { |
|
173 static Hb::SceneItems items = Hb::TitleBarItem | Hb::StatusBarItem; |
|
174 if(visible) |
|
175 { |
|
176 showItems(items); |
|
177 } |
|
178 else |
|
179 { |
|
180 hideItems(items); |
|
181 } |
148 } |
182 } |
149 |
183 |
150 void HelpCategoryView::ResetSearchPanel() |
184 void HelpCategoryView::ResetSearchPanel() |
151 { |
185 { |
152 foreach(QGraphicsItem *obj, mSearchPanel->childItems()) |
186 foreach(QGraphicsItem *obj, mSearchPanel->childItems()) |
229 //////////////////////////////////////////////////////////////////////////////////////////// |
260 //////////////////////////////////////////////////////////////////////////////////////////// |
230 // handle search panel event |
261 // handle search panel event |
231 |
262 |
232 void HelpCategoryView::onSearchPanelExitClicked() |
263 void HelpCategoryView::onSearchPanelExitClicked() |
233 { |
264 { |
234 setTitleBarVisible(true); |
265 if(mListSearch->model()->rowCount() == 0) |
235 HelpUIBuilder::load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH_NO_SRHPAL); |
266 { |
|
267 mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH_NO_SRHPAL_NO_MATCH); |
|
268 } |
|
269 else |
|
270 { |
|
271 mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH_NO_SRHPAL); |
|
272 } |
|
273 toolBar()->show(); |
236 } |
274 } |
237 |
275 |
238 void HelpCategoryView::onSearchPanelCriteriaChanged(const QString &criteria) |
276 void HelpCategoryView::onSearchPanelCriteriaChanged(const QString &criteria) |
239 { |
277 { |
240 mListSearch->setModel(HelpDataProvider::instance()->getSearchData(criteria)); |
278 HelpDataProvider::instance()->getSearchData(criteria); |
241 mListSearch->update(); |
279 if(mListSearch->model()->rowCount() == 0) |
|
280 { |
|
281 mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH_NO_MATCH); |
|
282 } |
|
283 else |
|
284 { |
|
285 mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH); |
|
286 } |
|
287 |
|
288 toolBar()->hide(); |
|
289 |
|
290 if(criteria.isEmpty()) |
|
291 { |
|
292 groupBox()->setHeading(hbTrId(TXT_SETLABEL_SEARCH)); |
|
293 } |
|
294 else |
|
295 { |
|
296 QString heading = qtTrId(TXT_SETLABEL_SEARCH_RESULTS); |
|
297 heading.append(COLON); |
|
298 heading.append(criteria); |
|
299 groupBox()->setHeading(heading); |
|
300 } |
|
301 } |
|
302 |
|
303 //////////////////////////////////////////////////////////////////////////////////////////// |
|
304 // handle virtual keyboard event |
|
305 |
|
306 void HelpCategoryView::onHandleKeypadOpen() |
|
307 { |
|
308 updateVisibleItems(false); |
|
309 qreal heightToSet = mainWindow()->layoutRect().height() - mVirtualKeyboard->keyboardArea().height(); |
|
310 this->setMaximumHeight(heightToSet); |
|
311 } |
|
312 |
|
313 void HelpCategoryView::onHandleKeypadClose() |
|
314 { |
|
315 updateVisibleItems(true); |
|
316 qreal mainHeight = mainWindow()->layoutRect().height(); |
|
317 qreal toolbarHeight = toolBar()->size().height(); |
|
318 qreal height = mainHeight - (toolBar()->isVisible() ? toolbarHeight : 0); |
|
319 this->setMaximumHeight(height); |
|
320 } |
|
321 |
|
322 //////////////////////////////////////////////////////////////////////////////////////////// |
|
323 // handle menu event |
|
324 void HelpCategoryView::onExpandAll() |
|
325 { |
|
326 QStandardItemModel* model = (QStandardItemModel*)(mListAll->model()); |
|
327 expandCollapseAllList(model->invisibleRootItem(),true); |
|
328 } |
|
329 |
|
330 void HelpCategoryView::onCollapseAll() |
|
331 { |
|
332 QStandardItemModel* model = (QStandardItemModel*)(mListAll->model()); |
|
333 expandCollapseAllList(model->invisibleRootItem(),false); |
242 } |
334 } |
243 |
335 |
244 |
336 |
245 // end of file |
337 // end of file |