userguide/src/HelpMainWindow.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 <hbnotificationdialog.h>
       
    19 #include <hbaction.h>
       
    20 
       
    21 #include "HelpCategoryView.h"
       
    22 #include "HelpContentsView.h"
       
    23 
       
    24 #include "HelpMainWindow.h"
       
    25 #include "HelpDocumentLoader.h"
       
    26 #include "HelpDataProvider.h"
       
    27 
       
    28 HelpMainWindow::HelpMainWindow() : 
       
    29 mCategoryView(NULL),
       
    30 mContentsView(NULL)
       
    31 {
       
    32     activateCategoryView();
       
    33 }
       
    34 
       
    35 HelpMainWindow::~HelpMainWindow()
       
    36 {
       
    37     HelpUIBuilder::destroyInstance();
       
    38     HelpDataProvider::destroyInstance();
       
    39 }
       
    40 
       
    41 void HelpMainWindow::onActivateView(HelpViewName viewName)
       
    42 {
       
    43 	switch(viewName)
       
    44 	{
       
    45 	    case HelpViewCategory:
       
    46             activateCategoryView();
       
    47 			break;
       
    48 
       
    49 	    case HelpViewContents:
       
    50             activateContentsView();
       
    51 			break;
       
    52 
       
    53 	    default:
       
    54 	        break;
       
    55 	}
       
    56 }
       
    57 
       
    58 void HelpMainWindow::activateCategoryView()
       
    59 {
       
    60     if(!mCategoryView)
       
    61     {
       
    62         HelpUIBuilder::load(QRC_DOCML_CATEGORY);
       
    63         mCategoryView = HelpUIBuilder::findWidget<HelpCategoryView*>(DOCML_VIEW_CATEGORY);
       
    64         addView(mCategoryView);
       
    65         mCategoryView->init();
       
    66         emit currentViewChanged(mCategoryView);
       
    67 		connectViewSignal(mCategoryView);
       
    68     }
       
    69 
       
    70     setCurrentView(mCategoryView);
       
    71 }
       
    72 
       
    73 void HelpMainWindow::activateContentsView()
       
    74 {
       
    75     if(!mContentsView)
       
    76     {
       
    77         HelpUIBuilder::load(QRC_DOCML_CONTENTS);
       
    78         mContentsView = HelpUIBuilder::findWidget<HelpContentsView*>(DOCML_VIEW_CONTENTS);
       
    79         addView(mContentsView);
       
    80         mContentsView->init();
       
    81 
       
    82         connectViewSignal(mContentsView);
       
    83     }
       
    84 
       
    85     setCurrentView(mContentsView);
       
    86 }
       
    87 
       
    88 void HelpMainWindow::connectViewSignal(const QObject *object)
       
    89 {
       
    90     connect(object, SIGNAL(activateView(HelpViewName)), this, SLOT(onActivateView(HelpViewName)));
       
    91     
       
    92     connect(object, SIGNAL(showAllList()), this, SLOT(onShowAllList()));
       
    93     connect(object, SIGNAL(showFindList()), this, SLOT(onShowFindList()));
       
    94     connect(object, SIGNAL(showOnlineSupport()), this, SLOT(onShowOnlineSupport()));
       
    95 }
       
    96 
       
    97 
       
    98 ////////////////////////////////////////////////////////////////////////////////////
       
    99 // handle view event
       
   100 
       
   101 void HelpMainWindow::onShowAllList()
       
   102 {
       
   103     activateCategoryView();
       
   104     mCategoryView->switchViewMode(HelpCategoryView::ViewModeAll);
       
   105 }
       
   106 
       
   107 void HelpMainWindow::onShowFindList()
       
   108 {
       
   109     activateCategoryView();
       
   110     mCategoryView->switchViewMode(HelpCategoryView::ViewModeSearch);
       
   111 }
       
   112 
       
   113 void HelpMainWindow::onShowOnlineSupport()
       
   114 {
       
   115     HbNotificationDialog *notificationDialog = new HbNotificationDialog();
       
   116     notificationDialog->setParent(this);
       
   117     notificationDialog->setTitle(URL_LINK_SUPPORT);
       
   118     notificationDialog->show();
       
   119 }
       
   120 
       
   121 // end of file
       
   122