diff -r 0a2ec6860a93 -r df6898e696c6 searchui/stateproviders/searchstateprovider/src/searchuiloader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/searchui/stateproviders/searchstateprovider/src/searchuiloader.cpp Mon Jul 26 12:45:04 2010 +0530 @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation of the uicontroller. + * + */ + +#include "searchuiloader.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml"; +const char *TOC_VIEW = "tocView"; +const char *TUT_SEARCHPANEL_WIDGET = "searchPanel"; +const char *TUT_LIST_VIEW = "listView"; + +SearchUiLoader *SearchUiLoader::m_instance = 0; +int SearchUiLoader::m_instanceCounter = 0; + +// --------------------------------------------------------------------------- +// SearchUiLoader::SearchUiLoader +// --------------------------------------------------------------------------- +SearchUiLoader::SearchUiLoader() : + mDocumentLoader(NULL), mView(NULL), mListWidget(NULL), mSearchPanel(NULL),mClient(NULL) + { + bool ok = false; + + mDocumentLoader = new HbDocumentLoader(); + + mDocumentLoader->load(SEARCHSTATEPROVIDER_DOCML, &ok); + + QGraphicsWidget *widget = mDocumentLoader->findWidget(TOC_VIEW); + + Q_ASSERT_X(ok && (widget != 0), "TOC_VIEW", "invalid view"); + + mView = qobject_cast (widget); + + if (mView) + { + mView->setTitle(hbTrId("txt_search_title_search")); + } + + mListWidget = qobject_cast (mDocumentLoader->findWidget( + TUT_LIST_VIEW)); + + Q_ASSERT_X(ok && (mListWidget != 0), "TUT_LIST_VIEW", "invalid viewocML file"); + + if (mListWidget) + { + HbAbstractViewItem *prototype = mListWidget->itemPrototypes().first(); + HbFrameBackground frame; + frame.setFrameGraphicsName("qtg_fr_list_normal"); + frame.setFrameType(HbFrameDrawer::NinePieces); + prototype->setDefaultFrame(frame); + HbListViewItem *prototypeListView = qobject_cast ( + prototype); + prototypeListView->setGraphicsSize(HbListViewItem::LargeIcon); + if (prototypeListView) + { + prototypeListView->setTextFormat(Qt::RichText); + } + HbAbstractItemView::ItemAnimations noCreationAndRemovalAnimations = + HbAbstractItemView::All; + noCreationAndRemovalAnimations ^= HbAbstractItemView::Appear; + noCreationAndRemovalAnimations ^= HbAbstractItemView::Disappear; + mListWidget->setEnabledAnimations(noCreationAndRemovalAnimations); + } + + mSearchPanel = qobject_cast ( + mDocumentLoader->findWidget(TUT_SEARCHPANEL_WIDGET)); + if (mSearchPanel) + { + Qt::InputMethodHints hints = mSearchPanel->inputMethodHints(); + hints |= Qt::ImhNoPredictiveText; + mSearchPanel->setInputMethodHints(hints); + mSearchPanel->setSearchOptionsEnabled(true); + mSearchPanel->setCancelEnabled(false); + } + + mMainWindow = hbInstance->allMainWindows().at(0); + HbAction *action = new HbAction(Hb::DoneNaviAction); + connect(action, SIGNAL(triggered()), this, SLOT(slotsendtobackground())); + mView->setNavigationAction(action); + mVirtualKeyboard = new HbShrinkingVkbHost(mView); + QCoreApplication::instance()->installEventFilter(this); + } +// --------------------------------------------------------------------------- +// SearchUiLoader::~SearchUiLoader +// --------------------------------------------------------------------------- +SearchUiLoader::~SearchUiLoader() + { + QCoreApplication::instance()->removeEventFilter(this); + + if (mDocumentLoader) + { + delete mDocumentLoader; + } + delete mClient; + } +// --------------------------------------------------------------------------- +// SearchUiLoader::slotsendtobackground +// --------------------------------------------------------------------------- +void SearchUiLoader::slotsendtobackground() + { + if (!mClient) + mClient = new TsTaskSettings; + mClient->setVisibility(false); + mListWidget->clear(); + mSearchPanel->setCriteria(QString()); + mMainWindow->lower(); + } +// --------------------------------------------------------------------------- +// SearchUiLoader::event +// --------------------------------------------------------------------------- +bool SearchUiLoader::eventFilter(QObject *obj, QEvent *event) + { + if (event->type() == QEvent::ApplicationActivate) + { + if (!mClient) + mClient = new TsTaskSettings; + mClient->setVisibility(true); + if (!(mListWidget->count())) + mSearchPanel->setFocus(); + return true; + } + return QObject::eventFilter(obj, event); + }