userguide/src/HelpDocumentLoader.cpp
changeset 13 1eb8015a8491
child 15 c0dfc135a46c
equal deleted inserted replaced
12:2cd891dccbbe 13:1eb8015a8491
       
     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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "HelpCategoryView.h"
       
    19 #include "HelpContentsView.h"
       
    20 #include "BrowserWrapper.h"
       
    21 
       
    22 #include "HelpDocumentLoader.h"
       
    23 
       
    24 
       
    25 ////////////////////////////////////////////////////////////////////////////////////////////
       
    26 
       
    27 class HelpDocumentLoader : public HbDocumentLoader
       
    28 {
       
    29 private:
       
    30     virtual QObject* createObject(const QString& type, const QString& name);
       
    31 };
       
    32     
       
    33 QObject* HelpDocumentLoader::createObject(const QString& type, const QString& name)
       
    34 {
       
    35     if(type == HelpCategoryView::staticMetaObject.className())
       
    36     {
       
    37         QObject* object = new HelpCategoryView;
       
    38         object->setObjectName(name);
       
    39         return object;
       
    40     }
       
    41 
       
    42     if(type == HelpContentsView::staticMetaObject.className())
       
    43     {
       
    44         QObject* object = new HelpContentsView;
       
    45         object->setObjectName(name);
       
    46         return object;
       
    47     }
       
    48     
       
    49     if(type == BrowserWrapper::staticMetaObject.className())    
       
    50     {
       
    51         QObject* object = new BrowserWrapper;
       
    52         object->setObjectName(name);
       
    53         return object;
       
    54     }
       
    55         
       
    56     return HbDocumentLoader::createObject(type, name);
       
    57 }
       
    58 
       
    59 
       
    60 ////////////////////////////////////////////////////////////////////////////////////////////
       
    61 
       
    62 HbDocumentLoader* gHelpUIBuilderInstance = NULL;
       
    63 
       
    64 HbDocumentLoader* HelpUIBuilder::instance()
       
    65 {
       
    66     if(!gHelpUIBuilderInstance)
       
    67     {
       
    68         gHelpUIBuilderInstance = new HelpDocumentLoader();
       
    69     }
       
    70 
       
    71     return gHelpUIBuilderInstance;
       
    72 }
       
    73 
       
    74 void HelpUIBuilder::destroyInstance()
       
    75 {
       
    76     delete gHelpUIBuilderInstance;
       
    77     gHelpUIBuilderInstance = NULL;
       
    78 }
       
    79 
       
    80 QObjectList HelpUIBuilder::load(const QString& fileName)
       
    81 { 
       
    82     bool ok = false;
       
    83     QObjectList list = instance()->load(fileName, &ok);
       
    84     Q_ASSERT_X(ok, "Help", "HelpUIBuilder load file");
       
    85     return list;
       
    86 }
       
    87 
       
    88 QObjectList HelpUIBuilder::load(const QString& fileName, const QString& section)
       
    89 {
       
    90     bool ok = false;
       
    91     QObjectList list = instance()->load(fileName, section, &ok);
       
    92     Q_ASSERT_X(ok, "Help", "HelpUIBuilder load section");
       
    93     return list;
       
    94 }
       
    95 
       
    96 QGraphicsWidget* HelpUIBuilder::findWidget(const QString& name)
       
    97 {
       
    98     return instance()->findWidget(name);
       
    99 }
       
   100 
       
   101 QObject* HelpUIBuilder::findObject(const QString& name)
       
   102 {
       
   103     return instance()->findObject(name);
       
   104 }
       
   105 
       
   106 
       
   107 
       
   108 // end of file
       
   109