15
|
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: Implementation of the uicontroller.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "searchuiloader.h"
|
|
19 |
#include <hbdocumentloader.h>
|
|
20 |
#include <hbview.h>
|
|
21 |
#include <hblistwidget.h>
|
|
22 |
#include <hbsearchpanel.h>
|
|
23 |
#include <hbabstractviewitem.h>
|
|
24 |
#include <hbframebackground.h>
|
|
25 |
#include <hblistviewitem.h>
|
|
26 |
#include <hbmainwindow.h>
|
|
27 |
#include <hbaction.h>
|
|
28 |
#include <hbinstance.h>
|
|
29 |
#include <tstasksettings.h>
|
|
30 |
#include <hbshrinkingvkbhost.h>
|
16
|
31 |
#include <qinputcontext.h>
|
|
32 |
|
15
|
33 |
const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml";
|
|
34 |
const char *TOC_VIEW = "tocView";
|
|
35 |
const char *TUT_SEARCHPANEL_WIDGET = "searchPanel";
|
|
36 |
const char *TUT_LIST_VIEW = "listView";
|
|
37 |
|
|
38 |
SearchUiLoader *SearchUiLoader::m_instance = 0;
|
|
39 |
int SearchUiLoader::m_instanceCounter = 0;
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
// SearchUiLoader::SearchUiLoader
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
SearchUiLoader::SearchUiLoader() :
|
16
|
45 |
mDocumentLoader(NULL), mView(NULL), mListWidget(NULL),
|
|
46 |
mSearchPanel(NULL), mClient(NULL), mMainWindow(NULL)
|
15
|
47 |
{
|
|
48 |
bool ok = false;
|
|
49 |
|
|
50 |
mDocumentLoader = new HbDocumentLoader();
|
|
51 |
|
|
52 |
mDocumentLoader->load(SEARCHSTATEPROVIDER_DOCML, &ok);
|
|
53 |
|
|
54 |
QGraphicsWidget *widget = mDocumentLoader->findWidget(TOC_VIEW);
|
|
55 |
|
|
56 |
Q_ASSERT_X(ok && (widget != 0), "TOC_VIEW", "invalid view");
|
|
57 |
|
|
58 |
mView = qobject_cast<HbView*> (widget);
|
|
59 |
|
|
60 |
if (mView)
|
|
61 |
{
|
|
62 |
mView->setTitle(hbTrId("txt_search_title_search"));
|
|
63 |
}
|
|
64 |
|
|
65 |
mListWidget = qobject_cast<HbListWidget *> (mDocumentLoader->findWidget(
|
|
66 |
TUT_LIST_VIEW));
|
|
67 |
|
|
68 |
Q_ASSERT_X(ok && (mListWidget != 0), "TUT_LIST_VIEW", "invalid viewocML file");
|
|
69 |
|
|
70 |
if (mListWidget)
|
|
71 |
{
|
|
72 |
HbAbstractViewItem *prototype = mListWidget->itemPrototypes().first();
|
|
73 |
HbFrameBackground frame;
|
|
74 |
frame.setFrameGraphicsName("qtg_fr_list_normal");
|
|
75 |
frame.setFrameType(HbFrameDrawer::NinePieces);
|
|
76 |
prototype->setDefaultFrame(frame);
|
|
77 |
HbListViewItem *prototypeListView = qobject_cast<HbListViewItem *> (
|
|
78 |
prototype);
|
|
79 |
prototypeListView->setGraphicsSize(HbListViewItem::LargeIcon);
|
|
80 |
if (prototypeListView)
|
|
81 |
{
|
|
82 |
prototypeListView->setTextFormat(Qt::RichText);
|
|
83 |
}
|
|
84 |
HbAbstractItemView::ItemAnimations noCreationAndRemovalAnimations =
|
|
85 |
HbAbstractItemView::All;
|
|
86 |
noCreationAndRemovalAnimations ^= HbAbstractItemView::Appear;
|
|
87 |
noCreationAndRemovalAnimations ^= HbAbstractItemView::Disappear;
|
|
88 |
mListWidget->setEnabledAnimations(noCreationAndRemovalAnimations);
|
|
89 |
}
|
|
90 |
|
|
91 |
mSearchPanel = qobject_cast<HbSearchPanel *> (
|
|
92 |
mDocumentLoader->findWidget(TUT_SEARCHPANEL_WIDGET));
|
|
93 |
if (mSearchPanel)
|
|
94 |
{
|
|
95 |
Qt::InputMethodHints hints = mSearchPanel->inputMethodHints();
|
|
96 |
hints |= Qt::ImhNoPredictiveText;
|
|
97 |
mSearchPanel->setInputMethodHints(hints);
|
|
98 |
mSearchPanel->setSearchOptionsEnabled(true);
|
|
99 |
mSearchPanel->setCancelEnabled(false);
|
|
100 |
}
|
|
101 |
|
16
|
102 |
mMainWindow = new SearchMainWindow();
|
|
103 |
connect(mMainWindow, SIGNAL(bringvkb()), this, SLOT(slotbringvkb()));
|
|
104 |
|
15
|
105 |
HbAction *action = new HbAction(Hb::DoneNaviAction);
|
|
106 |
connect(action, SIGNAL(triggered()), this, SLOT(slotsendtobackground()));
|
|
107 |
mView->setNavigationAction(action);
|
16
|
108 |
|
15
|
109 |
mVirtualKeyboard = new HbShrinkingVkbHost(mView);
|
16
|
110 |
|
|
111 |
mBringtoForground = true;
|
15
|
112 |
}
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
// SearchUiLoader::~SearchUiLoader
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
SearchUiLoader::~SearchUiLoader()
|
|
117 |
{
|
16
|
118 |
delete mMainWindow;
|
|
119 |
delete mDocumentLoader;
|
15
|
120 |
delete mClient;
|
|
121 |
}
|
|
122 |
// ---------------------------------------------------------------------------
|
|
123 |
// SearchUiLoader::slotsendtobackground
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
void SearchUiLoader::slotsendtobackground()
|
|
126 |
{
|
|
127 |
if (!mClient)
|
|
128 |
mClient = new TsTaskSettings;
|
|
129 |
mClient->setVisibility(false);
|
|
130 |
mListWidget->clear();
|
|
131 |
mSearchPanel->setCriteria(QString());
|
|
132 |
mMainWindow->lower();
|
16
|
133 |
mBringtoForground = true;
|
15
|
134 |
}
|
|
135 |
// ---------------------------------------------------------------------------
|
16
|
136 |
// SearchUiLoader::slotbringvkb
|
15
|
137 |
// ---------------------------------------------------------------------------
|
16
|
138 |
void SearchUiLoader::slotbringvkb()
|
15
|
139 |
{
|
16
|
140 |
if (mBringtoForground)
|
15
|
141 |
{
|
|
142 |
if (!mClient)
|
|
143 |
mClient = new TsTaskSettings;
|
|
144 |
mClient->setVisibility(true);
|
16
|
145 |
mSearchPanel->setFocus();
|
|
146 |
QInputContext *ic = qApp->inputContext();
|
|
147 |
if (ic)
|
|
148 |
{
|
|
149 |
mBringtoForground = false;
|
|
150 |
QEvent *event = new QEvent(QEvent::RequestSoftwareInputPanel);
|
|
151 |
ic->filterEvent(event);
|
|
152 |
delete event;
|
|
153 |
}
|
15
|
154 |
}
|
|
155 |
}
|
16
|
156 |
// ---------------------------------------------------------------------------
|
|
157 |
// SearchMainWindow::slotViewReady
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
void SearchMainWindow::slotViewReady()
|
|
160 |
{
|
|
161 |
emit bringvkb();
|
|
162 |
}
|