userguide/src/BrowserWrapper.cpp
changeset 13 1eb8015a8491
child 18 375271912456
child 24 bce8d4d2cc72
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 <QGraphicsScene>
       
    19 #include <QGraphicsProxyWidget>
       
    20 #include <QGraphicsLinearLayout>
       
    21 
       
    22 #include "HelpDocumentLoader.h"
       
    23 #include "HelpCommon.h"
       
    24 #include "BrowserWrapper.h"
       
    25 
       
    26 BrowserWrapper::BrowserWrapper()
       
    27 {
       
    28 }
       
    29 
       
    30 BrowserWrapper::~BrowserWrapper()
       
    31 {
       
    32 }
       
    33 
       
    34 void BrowserWrapper::init()
       
    35 {
       
    36 	mWebView = new QGraphicsWebView();
       
    37     mWebView->setZoomFactor(1.5);
       
    38     mWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
       
    39     connect(mWebView, SIGNAL(linkClicked(const QUrl&)), this, SIGNAL(linkClicked(const QUrl&)));
       
    40     
       
    41     QGraphicsLinearLayout* vLayout = new QGraphicsLinearLayout(this);
       
    42     vLayout->setOrientation(Qt::Vertical);
       
    43     vLayout->addItem(mWebView);
       
    44     vLayout->setContentsMargins(0,0,0,0);
       
    45     setLayout(vLayout);
       
    46 }
       
    47 
       
    48 void BrowserWrapper::setHtml(const QString& html, const QUrl& baseUrl)
       
    49 {
       
    50     mWebView->setHtml(html, baseUrl);
       
    51 
       
    52     if(!mHistory.count() || mHistory.top()!=baseUrl)
       
    53     {
       
    54         mHistory.append(baseUrl);
       
    55     }
       
    56 }
       
    57 
       
    58 void BrowserWrapper::clearHistory()
       
    59 {
       
    60     mHistory.clear();
       
    61 }
       
    62 
       
    63 bool BrowserWrapper::canGoBack()
       
    64 {
       
    65     return (mHistory.count() > 1);
       
    66 }
       
    67 
       
    68 void BrowserWrapper::back()
       
    69 {
       
    70     if(canGoBack())
       
    71     {
       
    72         mHistory.pop();
       
    73         QUrl url = mHistory.top();
       
    74         emit urlChanged(url);
       
    75     }
       
    76 }
       
    77 
       
    78 
       
    79 // end of file
       
    80