homescreenapp/stateplugins/hsapplibrarystateplugin/src/hssearchviewbuilder.cpp
changeset 77 4b195f3bea29
equal deleted inserted replaced
61:2b1b11a301d2 77:4b195f3bea29
       
     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: Search View Builder
       
    15  *
       
    16  */
       
    17 
       
    18 #include <HbSearchPanel>
       
    19 #include <HbView>
       
    20 #include <HbListView>
       
    21 #include <HbGroupBox>
       
    22 #include "hssearchviewbuilder.h"
       
    23 
       
    24 const char *searchDocmlFile           = ":/xml/searchview.docml";
       
    25 const char *searchViewLabeledList     = "searchViewLabeledList";
       
    26 const char *searchViewList            = "searchViewList";
       
    27 const char *searchViewLabeledEmpty    = "searchViewLabeledEmpty";
       
    28 const char *searchViewEmpty           = "searchViewEmpty";
       
    29 
       
    30 
       
    31 /*!
       
    32     \class HsSearchViewBuilder
       
    33     \ingroup group_hsmenustateplugin
       
    34 
       
    35     \brief Search View Builder
       
    36 
       
    37     Reads UI object from Application Library Search docml
       
    38 
       
    39     \sa HsMenuView
       
    40 */
       
    41 
       
    42 /*!
       
    43  Constructor. Loads UI objects from docml.
       
    44  */
       
    45 HsSearchViewBuilder::HsSearchViewBuilder() : mLoader(new HbDocumentLoader()),
       
    46     mLabledContext(false)
       
    47 {
       
    48     bool loadStatusOk(false);
       
    49     mLoadedObjects =
       
    50             mLoader->load(searchDocmlFile, &loadStatusOk).toSet();
       
    51     Q_ASSERT(loadStatusOk);
       
    52 }
       
    53 
       
    54 /*!
       
    55  Destructor. Deletes seto of loaded objects.
       
    56  */
       
    57 HsSearchViewBuilder::~HsSearchViewBuilder()
       
    58 {
       
    59     qDeleteAll(mLoadedObjects);
       
    60 }
       
    61 
       
    62 /*!
       
    63  \return Pointer to the view.
       
    64  Memory ownership is not changed.
       
    65  */
       
    66 HbView *HsSearchViewBuilder::searchView()
       
    67 {
       
    68     return qobject_cast<HbView *>(mLoader->findWidget("view"));
       
    69 }
       
    70 
       
    71 /*!
       
    72  \return Pointer to list view.
       
    73  The pointer is valid until the HsSearchViewBuilder instance is destroyed.
       
    74  Memory ownership is not changed.
       
    75  */
       
    76 HbListView *HsSearchViewBuilder::searchListView()
       
    77 {
       
    78     return qobject_cast<HbListView *>(mLoader->findWidget("listView"));
       
    79 }
       
    80 
       
    81 /*!
       
    82  \return Pointer to search panel.
       
    83  The pointer is valid until the HsSearchViewBuilder instance is destroyed.
       
    84  Memory ownership is not changed.
       
    85  */
       
    86 HbSearchPanel *HsSearchViewBuilder::searchPanel()
       
    87 {
       
    88     return qobject_cast<HbSearchPanel *>(mLoader->findWidget("searchPanel"));
       
    89 }
       
    90 
       
    91 /*!
       
    92  \return Pointer to the view label.
       
    93  The pointer is valid until the HsSearchViewBuilder instance is destroyed.
       
    94  Memory ownership is not changed.
       
    95  */
       
    96 HbGroupBox *HsSearchViewBuilder::searchViewLabel()
       
    97 {
       
    98     return qobject_cast<HbGroupBox *>(mLoader->findWidget("label"));
       
    99 }
       
   100 
       
   101 /*!
       
   102  Switches HsSearchViewBuilder to labeled view layout.
       
   103  */
       
   104 void HsSearchViewBuilder::setSearchLabledContext()
       
   105 {
       
   106     mLabledContext = true;
       
   107 }
       
   108 
       
   109 /*!
       
   110  \return true if section was succesfull loaded.
       
   111  Loads proper empty docml section.
       
   112  */
       
   113 bool HsSearchViewBuilder::loadViewEmptySection()
       
   114 {
       
   115     bool loadStatusOk(false);
       
   116     if(mLabledContext) {
       
   117         mLoadedObjects |= mLoader->load(
       
   118                 searchDocmlFile,
       
   119                 searchViewLabeledEmpty,
       
   120                 &loadStatusOk).toSet();
       
   121     } else {
       
   122         mLoadedObjects |= mLoader->load(
       
   123                 searchDocmlFile,
       
   124                 searchViewEmpty,
       
   125                 &loadStatusOk).toSet();
       
   126     }
       
   127     Q_ASSERT(loadStatusOk);
       
   128     return loadStatusOk;
       
   129 }
       
   130 
       
   131 /*!
       
   132  \return true if section was succesfull loaded.
       
   133  Loads proper list docml section.
       
   134  */
       
   135 bool HsSearchViewBuilder::loadViewListSection()
       
   136 {
       
   137     bool loadStatusOk(false);
       
   138     if(mLabledContext) {
       
   139         mLoadedObjects |= mLoader->load(
       
   140                 searchDocmlFile,
       
   141                 searchViewLabeledList,
       
   142                 &loadStatusOk).toSet();
       
   143     } else {
       
   144         mLoadedObjects |= mLoader->load(
       
   145                 searchDocmlFile,
       
   146                 searchViewList,
       
   147                 &loadStatusOk).toSet();
       
   148     }
       
   149     Q_ASSERT(loadStatusOk);
       
   150     return loadStatusOk;
       
   151 }