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: Menu search. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <qdebug.h> |
|
19 #include "hsmenuitemmodel.h" |
|
20 #include "hsmenuview.h" |
|
21 #include "hsmenusearch.h" |
|
22 |
|
23 /*! |
|
24 \class Menu Search |
|
25 \ingroup group_hsmenustateplugin |
|
26 |
|
27 \brief Menu View |
|
28 |
|
29 Provides handler for \a criteriaChanged signal emited |
|
30 by menu view search panel |
|
31 |
|
32 \sa HsMenuView |
|
33 */ |
|
34 |
|
35 /*! |
|
36 Constructor |
|
37 \param menuView Menu view the object is doing search job for. |
|
38 */ |
|
39 HsMenuSearch::HsMenuSearch(HsMenuView *menuView): mMenuView(menuView) |
|
40 { |
|
41 } |
|
42 |
|
43 /*! |
|
44 Looks up for item and if found scrolls to it. |
|
45 \param criteriaStr The item name to find. |
|
46 */ |
|
47 void HsMenuSearch::findItem(QString criteriaStr) |
|
48 { |
|
49 qDebug() << QString("HsMenuSearch::findItem: %1").arg(criteriaStr); |
|
50 HSMENUTEST_FUNC_ENTRY("HsMenuSearch::findItem"); |
|
51 |
|
52 if ("" != criteriaStr) { |
|
53 const HsMenuItemModel *const model = mMenuView->model(); |
|
54 |
|
55 const QModelIndexList list = |
|
56 model->match( |
|
57 model->index(0, 0), |
|
58 CaItemModel::TextRole, |
|
59 criteriaStr); |
|
60 |
|
61 if (list.count() > 0) { |
|
62 qDebug() << QString("HsMenuSearch::findItem:row %1"). arg( |
|
63 list.at(0).row()); |
|
64 |
|
65 mMenuView->scrollToWithoutHidingSearchPanel( |
|
66 list.at(0), |
|
67 HbAbstractItemView::PositionAtTop); |
|
68 } |
|
69 } |
|
70 |
|
71 HSMENUTEST_FUNC_EXIT("HsMenuSearch::findItem"); |
|
72 } |
|