ginebra2/ContentViews/WebView.cpp
changeset 6 1c3b8676e58c
child 16 3c88a81ff781
equal deleted inserted replaced
5:0f2326c2a325 6:1c3b8676e58c
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 *
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 *
       
    20 */
       
    21 #include "WebView.h"
       
    22 
       
    23 #include "browserpagefactory.h"
       
    24 #include "wrtbrowsercontainer.h"
       
    25 
       
    26 #include <QWebFrame>
       
    27 #include <QWebPage>
       
    28 
       
    29 namespace GVA {
       
    30 
       
    31 WebView::WebView()
       
    32     : QGraphicsWebView()
       
    33     , m_webPage(0)
       
    34 {}
       
    35 
       
    36 WebView::~WebView()
       
    37 {}
       
    38 
       
    39 QWebPage* WebView::page() const
       
    40 {
       
    41     return m_webPage;
       
    42 }
       
    43 
       
    44 void WebView::setPage(QWebPage* page)
       
    45 {
       
    46     if (m_webPage == page)
       
    47         return;
       
    48 
       
    49     if (m_webPage) {
       
    50         disconnect(m_webPage->mainFrame(), 0, this, 0);
       
    51         m_webPage->setView(0);
       
    52     }
       
    53 
       
    54     m_webPage = page;
       
    55 
       
    56     if (!m_webPage)
       
    57         m_webPage = createWebPage();
       
    58 
       
    59     QGraphicsWebView::setPage(m_webPage);
       
    60 
       
    61     emit titleChanged(title());
       
    62     emit urlChanged(url());
       
    63 }
       
    64 
       
    65 QWebPage* WebView::createWebPage()
       
    66 {
       
    67     return reinterpret_cast<QWebPage*>(BrowserPageFactory::openBrowserPage());
       
    68 }
       
    69 
       
    70 }//namespace GVA