ginebra2/ContentViews/GWebContentView.cpp
author hgs
Fri, 17 Sep 2010 12:11:40 -0400
changeset 12 afcd8e6d025b
parent 9 b39122337a00
child 16 3c88a81ff781
permissions -rw-r--r--
201037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
3
hgs
parents: 0
diff changeset
     4
*
hgs
parents: 0
diff changeset
     5
* This program is free software: you can redistribute it and/or modify
hgs
parents: 0
diff changeset
     6
* it under the terms of the GNU Lesser General Public License as published by
hgs
parents: 0
diff changeset
     7
* the Free Software Foundation, version 2.1 of the License.
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
3
hgs
parents: 0
diff changeset
     9
* This program is distributed in the hope that it will be useful,
hgs
parents: 0
diff changeset
    10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
hgs
parents: 0
diff changeset
    11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
hgs
parents: 0
diff changeset
    12
* GNU Lesser General Public License for more details.
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
3
hgs
parents: 0
diff changeset
    14
* You should have received a copy of the GNU Lesser General Public License
hgs
parents: 0
diff changeset
    15
* along with this program.  If not,
hgs
parents: 0
diff changeset
    16
* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*
12
hgs
parents: 9
diff changeset
    18
* Description :
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
*
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
*/
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include "GWebContentView.h"
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include "GWebContentViewWidget.h"
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include "GWebContentViewJSObject.h"
3
hgs
parents: 0
diff changeset
    25
#include "SuperPageView.h"
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include "ChromeWidget.h"
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "WebViewEventContext.h"
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "browserpagefactory.h"
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "wrtbrowsercontainer.h"
3
hgs
parents: 0
diff changeset
    30
hgs
parents: 0
diff changeset
    31
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
    32
#include "WebContentViewWidget.h"
hgs
parents: 0
diff changeset
    33
#endif
hgs
parents: 0
diff changeset
    34
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include "webpagecontroller.h"
3
hgs
parents: 0
diff changeset
    36
#include "Utilities.h"
hgs
parents: 0
diff changeset
    37
#include "GSuperWebPage.h"
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#ifndef NO_QSTM_GESTURE
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "qstmgestureevent.h"
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#endif
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include <QGraphicsWebView>
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#include <QWebHistory>
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#include <QWebPage>
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
#include <QWebFrame>
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include <QTimeLine>
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#include <QDebug>
3
hgs
parents: 0
diff changeset
    48
#include <QtGui>
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
namespace GVA {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
  // ----------------------------------------------------------
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
  const qreal KZoomInStep = 1.05;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
  const qreal KZoomOutStep = 0.95238;
12
hgs
parents: 9
diff changeset
    57
  const qreal KInitialZoomFactorValue = 0.653061;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
  GWebContentView::GWebContentView(ChromeWidget *chrome, QObject * parent, const QString &objectName)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    : ControllableViewBase(parent),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
      m_networkMgr(0),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
      m_chrome(chrome),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
      m_timeLine(0),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
      m_zoomIn(false),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
      m_backEnabled(false),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
      m_forwardEnabled(false),
3
hgs
parents: 0
diff changeset
    66
      m_sharedPage(0),
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
      m_currentSuperPage(m_superPages.begin()),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
      m_currentPageIsSuperPage(false),
3
hgs
parents: 0
diff changeset
    69
      m_timer(NULL),
12
hgs
parents: 9
diff changeset
    70
      m_enabled(true),
hgs
parents: 9
diff changeset
    71
      m_savedZoomValueInView(KInitialZoomFactorValue) 
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
      setObjectName(objectName);
3
hgs
parents: 0
diff changeset
    74
      WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage();
hgs
parents: 0
diff changeset
    75
hgs
parents: 0
diff changeset
    76
      setActions();
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
3
hgs
parents: 0
diff changeset
    78
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
    79
      m_widget = new WebContentViewWidget(parent, page);
hgs
parents: 0
diff changeset
    80
      connect(m_widget
hgs
parents: 0
diff changeset
    81
              , SIGNAL(updateZoomActions(bool,bool))
hgs
parents: 0
diff changeset
    82
              , this
hgs
parents: 0
diff changeset
    83
              , SLOT(setZoomActions(bool, bool)));
hgs
parents: 0
diff changeset
    84
#else
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
      m_widget = new GWebContentViewWidget(parent, this, page);
3
hgs
parents: 0
diff changeset
    86
#endif
hgs
parents: 0
diff changeset
    87
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
#ifndef __gva_no_chrome__
3
hgs
parents: 0
diff changeset
    89
      setJSObject(objectName);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
#endif
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
      m_networkMgr = webWidget()->page()->networkAccessManager();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
      webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
      webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
3
hgs
parents: 0
diff changeset
    96
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
#ifdef NO_QSTM_GESTURE
3
hgs
parents: 0
diff changeset
    98
      m_touchNavigation = new GContentViewTouchNavigation(page, m_widget);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
      m_touchNavigation->setChromeWidget(m_chrome);
3
hgs
parents: 0
diff changeset
   100
      m_touchNavigation->setParent(m_jsObject);
hgs
parents: 0
diff changeset
   101
      m_touchNavigation->setObjectName("touchNav");
hgs
parents: 0
diff changeset
   102
      safe_connect(m_touchNavigation, SIGNAL(mouseEvent(QEvent::Type)) , this, SIGNAL(contentViewMouseEvent(QEvent::Type)));
hgs
parents: 0
diff changeset
   103
      safe_connect(m_touchNavigation, SIGNAL(longPressEvent(QPoint)),
hgs
parents: 0
diff changeset
   104
                   webWidget(), SLOT(onLongPressEvent(QPoint)));
hgs
parents: 0
diff changeset
   105
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
#endif
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
      WRT::WrtBrowserContainer * wrtPage = static_cast<WRT::WrtBrowserContainer *>(page);
3
hgs
parents: 0
diff changeset
   108
      if (wrtPage) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
          wrtPage->setWebWidget(webWidget());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
          pageCreated(wrtPage);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
      connectAll();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
  GWebContentView::~GWebContentView() {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
      disconnect(m_jsObject);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
      disconnect(webWidget());
3
hgs
parents: 0
diff changeset
   119
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
      delete m_touchNavigation;
3
hgs
parents: 0
diff changeset
   121
#endif
hgs
parents: 0
diff changeset
   122
      foreach(QAction * action, m_actions) {
hgs
parents: 0
diff changeset
   123
          delete action;
hgs
parents: 0
diff changeset
   124
      }
hgs
parents: 0
diff changeset
   125
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
      delete m_widget;
3
hgs
parents: 0
diff changeset
   127
      foreach(GSuperWebPage *page, m_superPages) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
          delete page;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
3
hgs
parents: 0
diff changeset
   132
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   133
void GWebContentView::zoomIn(qreal deltaPercent)
hgs
parents: 0
diff changeset
   134
{
hgs
parents: 0
diff changeset
   135
    //FIX ME : Do we need deltaPercent?
hgs
parents: 0
diff changeset
   136
    Q_UNUSED(deltaPercent);
hgs
parents: 0
diff changeset
   137
    m_widget->setPageZoom(true);
hgs
parents: 0
diff changeset
   138
}
hgs
parents: 0
diff changeset
   139
hgs
parents: 0
diff changeset
   140
void GWebContentView::zoomOut(qreal deltaPercent)
hgs
parents: 0
diff changeset
   141
{
hgs
parents: 0
diff changeset
   142
    //FIX ME : Do we need deltaPercent?
hgs
parents: 0
diff changeset
   143
    Q_UNUSED(deltaPercent);
hgs
parents: 0
diff changeset
   144
    m_widget->setPageZoom(false);
hgs
parents: 0
diff changeset
   145
}
hgs
parents: 0
diff changeset
   146
#endif
hgs
parents: 0
diff changeset
   147
hgs
parents: 0
diff changeset
   148
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
void GWebContentView::bitmapZoomStop()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
    if (m_timer) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
        m_timer->stop();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
        disconnect(m_timer,SIGNAL(timeout()));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
        delete m_timer;
3
hgs
parents: 0
diff changeset
   155
        m_timer = NULL;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    qreal zoomFactor = m_value * webWidget()->zoomFactor();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    ((zoomFactor+0.001) >= webWidget()->maximumScale() )? webWidget()->setZoomFactor(webWidget()->maximumScale()):webWidget()->setZoomFactor(zoomFactor);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    webWidget()->bitmapZoomCleanup();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
void GWebContentView::zoomP()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
    if ((m_value * webWidget()->zoomFactor()) >  webWidget()->maximumScale()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
        if (m_timer && m_timer->isActive())
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
            bitmapZoomStop();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    }else {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
        if (m_timer->isSingleShot()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
            m_timer->setSingleShot(false);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
            m_timer->start(1);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
        }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
        webWidget()->setBitmapZoom(m_value * webWidget()->zoomFactor());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
        m_value *= KZoomInStep;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
void GWebContentView::zoomN()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    if ((m_value * webWidget()->zoomFactor()) <  webWidget()->minimumScale()){
12
hgs
parents: 9
diff changeset
   180
       // if (m_timer && m_timer->isActive())
3
hgs
parents: 0
diff changeset
   181
            bitmapZoomStop();
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
    }else {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
        if (m_timer->isSingleShot()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
            m_timer->setSingleShot(false);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
            m_timer->start(1);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
        }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
        webWidget()->setBitmapZoom(m_value * webWidget()->zoomFactor());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
        m_value *= KZoomOutStep;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
3
hgs
parents: 0
diff changeset
   192
void GWebContentView::zoomIn(qreal deltaPercent)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
    Q_UNUSED(deltaPercent)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
    if (webWidget() && webWidget()->isUserScalable()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
        if (m_timer && m_timer->isActive()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
            if (!m_timer->isSingleShot())
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
                m_value /= KZoomInStep;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
            bitmapZoomStop();
3
hgs
parents: 0
diff changeset
   200
            return;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
        }else if (!m_timer)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
            m_timer = new QTimer(this);
3
hgs
parents: 0
diff changeset
   203
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
        m_value = KZoomInStep;
3
hgs
parents: 0
diff changeset
   205
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
        if ((m_value * webWidget()->zoomFactor()) <  webWidget()->maximumScale()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
            webWidget()->createPageSnapShot();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
            connect(m_timer,SIGNAL(timeout()),this,SLOT(zoomP()));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
            zoomP();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
            m_timer->setSingleShot(true);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
            m_timer->start(500);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
        }else {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
            delete m_timer;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
            m_timer = NULL;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
            webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
        }
12
hgs
parents: 9
diff changeset
   217
        setSavedZoomValueInView(m_value * webWidget()->zoomFactor());
3
hgs
parents: 0
diff changeset
   218
    }
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
3
hgs
parents: 0
diff changeset
   221
void GWebContentView::zoomOut(qreal deltaPercent)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
    Q_UNUSED(deltaPercent)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    if (webWidget() && webWidget()->isUserScalable()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
        if (m_timer && m_timer->isActive()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
            if (!m_timer->isSingleShot())
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
                m_value /= KZoomOutStep;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
            bitmapZoomStop();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
            return;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
        }else if (!m_timer)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
            m_timer = new QTimer(this);
3
hgs
parents: 0
diff changeset
   232
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
        m_value = KZoomOutStep;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
        if ((m_value * webWidget()->zoomFactor()) >  webWidget()->minimumScale()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
            webWidget()->createPageSnapShot();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
            connect(m_timer,SIGNAL(timeout()),this,SLOT(zoomN()));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
            zoomN();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
            m_timer->setSingleShot(true);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
            m_timer->start(500);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
        }else {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
            delete m_timer;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
            m_timer = NULL;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
            webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
        }
12
hgs
parents: 9
diff changeset
   246
        setSavedZoomValueInView(m_value * webWidget()->zoomFactor());
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
3
hgs
parents: 0
diff changeset
   250
#endif
9
hgs
parents: 3
diff changeset
   251
hgs
parents: 3
diff changeset
   252
hgs
parents: 3
diff changeset
   253
bool GWebContentView::gesturesEnabled() const 
hgs
parents: 3
diff changeset
   254
{ 
hgs
parents: 3
diff changeset
   255
#ifndef BEDROCK_TILED_BACKING_STORE
hgs
parents: 3
diff changeset
   256
    return m_touchNavigation->enabled(); 
hgs
parents: 3
diff changeset
   257
#else	
hgs
parents: 3
diff changeset
   258
    return m_widget->gesturesEnabled();
hgs
parents: 3
diff changeset
   259
#endif
hgs
parents: 3
diff changeset
   260
}
hgs
parents: 3
diff changeset
   261
hgs
parents: 3
diff changeset
   262
void GWebContentView::setGesturesEnabled(bool value) 
hgs
parents: 3
diff changeset
   263
{ 
hgs
parents: 3
diff changeset
   264
#ifndef BEDROCK_TILED_BACKING_STORE		  
hgs
parents: 3
diff changeset
   265
    m_touchNavigation->setEnabled(value); 
hgs
parents: 3
diff changeset
   266
#else
hgs
parents: 3
diff changeset
   267
    m_widget->setGesturesEnabled(value);
hgs
parents: 3
diff changeset
   268
#endif
hgs
parents: 3
diff changeset
   269
}
hgs
parents: 3
diff changeset
   270
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
  void GWebContentView::connectAll() {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    //qDebug() << "GWebContentView::connectAll: " << widget();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
#ifndef __gva_no_chrome__
3
hgs
parents: 0
diff changeset
   275
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    safe_connect(widget(), SIGNAL(contextEvent(::WebViewEventContext *)),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
                 m_jsObject, SLOT(onContextEvent(::WebViewEventContext *)));
3
hgs
parents: 0
diff changeset
   278
#else
hgs
parents: 0
diff changeset
   279
    safe_connect(this
hgs
parents: 0
diff changeset
   280
                 , SIGNAL(contextEvent(::WebViewEventContext*))
hgs
parents: 0
diff changeset
   281
                 ,  m_jsObject
hgs
parents: 0
diff changeset
   282
                 , SLOT(onContextEvent(::WebViewEventContext*)));
hgs
parents: 0
diff changeset
   283
hgs
parents: 0
diff changeset
   284
    safe_connect(m_widget
hgs
parents: 0
diff changeset
   285
                , SIGNAL(contextEventObject(QWebHitTestResult*))
hgs
parents: 0
diff changeset
   286
                , this
hgs
parents: 0
diff changeset
   287
                , SLOT(handleContextEventObject(QWebHitTestResult*)));
hgs
parents: 0
diff changeset
   288
hgs
parents: 0
diff changeset
   289
    safe_connect(m_widget
hgs
parents: 0
diff changeset
   290
                 , SIGNAL(viewScrolled(QPoint&, QPoint&))
hgs
parents: 0
diff changeset
   291
                 , this
hgs
parents: 0
diff changeset
   292
                 , SLOT(handleViewScrolled(QPoint&, QPoint&)));
9
hgs
parents: 3
diff changeset
   293
hgs
parents: 3
diff changeset
   294
    safe_connect(m_widget
hgs
parents: 3
diff changeset
   295
                 , SIGNAL(mouseEvent(QEvent::Type)) 
hgs
parents: 3
diff changeset
   296
                 , this
hgs
parents: 3
diff changeset
   297
                 , SIGNAL(contentViewMouseEvent(QEvent::Type)));
hgs
parents: 3
diff changeset
   298
hgs
parents: 3
diff changeset
   299
    
3
hgs
parents: 0
diff changeset
   300
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    QObject::connect(webWidget(), SIGNAL(titleChanged(const QString &)), m_jsObject, SIGNAL(titleChanged(const QString &)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    QObject::connect(webWidget(), SIGNAL(loadStarted()), m_jsObject, SIGNAL(loadStarted()));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    QObject::connect(webWidget(), SIGNAL(loadProgress(int)), m_jsObject, SIGNAL(loadProgress(int)));
3
hgs
parents: 0
diff changeset
   304
    QObject::connect(webWidget(), SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
#endif
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    QObject::connect(webWidget(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted()));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    QObject::connect(webWidget(), SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    QObject::connect(webWidget(), SIGNAL(urlChanged(const QUrl&)), this, SLOT(onUrlChanged(const QUrl&)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
#ifndef __gva_no_chrome__
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    QObject::connect(this, SIGNAL(urlChanged(const QString&)), m_jsObject, SIGNAL(urlChanged(const QString&)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
    QObject::connect(this, SIGNAL(backEnabled(bool)), m_jsObject, SIGNAL(backEnabled(bool)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
    QObject::connect(this, SIGNAL(forwardEnabled(bool)), m_jsObject, SIGNAL(forwardEnabled(bool)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    QObject::connect(this, SIGNAL(loadFinished(bool)), m_jsObject, SIGNAL(loadFinished(bool)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
    QObject::connect(this, SIGNAL(secureConnection(bool)), m_jsObject, SIGNAL(secureConnection(bool)));
9
hgs
parents: 3
diff changeset
   315
3
hgs
parents: 0
diff changeset
   316
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
    connect(m_touchNavigation, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int)));
9
hgs
parents: 3
diff changeset
   318
#else
hgs
parents: 3
diff changeset
   319
    connect(this, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int)));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
#endif
9
hgs
parents: 3
diff changeset
   321
hgs
parents: 3
diff changeset
   322
	QObject::connect(this, SIGNAL(superPageShown(const QString&)), m_jsObject, SIGNAL(superPageShown(const QString&)));         
3
hgs
parents: 0
diff changeset
   323
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
    connect(WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
            this, SLOT(pageCreated(WRT::WrtBrowserContainer*)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
    connect(WebPageController::getSingleton(), SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)),
3
hgs
parents: 0
diff changeset
   327
            this, SLOT(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)));
hgs
parents: 0
diff changeset
   328
    connect(WebPageController::getSingleton(), SIGNAL(showMessageBox(WRT::MessageBoxProxy*)),
hgs
parents: 0
diff changeset
   329
            this, SLOT(showMessageBox(WRT::MessageBoxProxy*)));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
  QVariant GWebContentView::getContentWindowObject() {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
    try {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
        return webWidget()->page()->mainFrame()->evaluateJavaScript("window");
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
    catch(...) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
        qDebug() << "GWebContentView::getContentWindowObject: caught expection";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
        return QVariant();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
  QGraphicsWidget* GWebContentView::widget() const {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
    return static_cast<QGraphicsWidget*>(m_widget);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
3
hgs
parents: 0
diff changeset
   346
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   347
  QGraphicsWebView* GWebContentView::webWidget() const {
hgs
parents: 0
diff changeset
   348
    return m_widget->webView();
hgs
parents: 0
diff changeset
   349
  }
hgs
parents: 0
diff changeset
   350
#else
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
  GWebContentViewWidget *GWebContentView::webWidget() const {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
    return m_widget;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
  }
3
hgs
parents: 0
diff changeset
   354
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
  QString GWebContentView::title() const {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
    return webWidget()->title();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
  QUrl GWebContentView::url() {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
    return webWidget()->url();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
  QWebPage* GWebContentView::wrtPage() {
3
hgs
parents: 0
diff changeset
   365
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   366
    return m_widget->page();
hgs
parents: 0
diff changeset
   367
#else
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    return m_widget->wrtPage();
3
hgs
parents: 0
diff changeset
   369
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
3
hgs
parents: 0
diff changeset
   372
  void GWebContentView::setActions(){
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
3
hgs
parents: 0
diff changeset
   374
      QAction* action;
hgs
parents: 0
diff changeset
   375
      action = m_actions["zoomIn"] =  new QAction("zoomIn", this);
hgs
parents: 0
diff changeset
   376
      action->setObjectName("zoomIn");
hgs
parents: 0
diff changeset
   377
      connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
3
hgs
parents: 0
diff changeset
   379
      action = m_actions["zoomOut"] = new QAction("zoomOut", this);
hgs
parents: 0
diff changeset
   380
      action->setObjectName("zoomOut");
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
      /* Disable zoomOut action initially as we are the the minimum scale */
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
      /* Revisit this to determine whether we can use the change signal to
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
       * set the zoomOut button image initially as well
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
       */
3
hgs
parents: 0
diff changeset
   385
      action->setEnabled(false);
hgs
parents: 0
diff changeset
   386
      connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
hgs
parents: 0
diff changeset
   387
hgs
parents: 0
diff changeset
   388
      action = m_actions["zoom"] = new QAction("zoom", this);
hgs
parents: 0
diff changeset
   389
      action->setObjectName("zoom");
hgs
parents: 0
diff changeset
   390
hgs
parents: 0
diff changeset
   391
hgs
parents: 0
diff changeset
   392
      action =  m_actions["winview"]=  new QAction("winview", this);
hgs
parents: 0
diff changeset
   393
      action->setObjectName("winview");
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
3
hgs
parents: 0
diff changeset
   395
hgs
parents: 0
diff changeset
   396
      action = m_actions["menu"] =  new QAction("menu", this);
hgs
parents: 0
diff changeset
   397
      action->setObjectName("menu");
hgs
parents: 0
diff changeset
   398
hgs
parents: 0
diff changeset
   399
      action = m_actions["mostvisited"] =  new QAction("mostvisited", this);
hgs
parents: 0
diff changeset
   400
      action->setObjectName("mostvisited");
hgs
parents: 0
diff changeset
   401
hgs
parents: 0
diff changeset
   402
      action = m_actions["toggletb"] = new QAction("toggletb", this);
hgs
parents: 0
diff changeset
   403
      action->setObjectName("toggletb");
hgs
parents: 0
diff changeset
   404
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
  void GWebContentView::triggerAction(const QString & action)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
    QWebPage::WebAction webAction;
3
hgs
parents: 0
diff changeset
   410
    if (action=="Stop")
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
      webAction = QWebPage::Stop;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
    else if (action=="Back")
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
      webAction = QWebPage::Back;
3
hgs
parents: 0
diff changeset
   414
    else if (action=="Reload")
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
      webAction = QWebPage::Reload;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
    else if (action=="Forward")
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
      webAction = QWebPage::Forward;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
    else
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
      return;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
    webWidget()->triggerPageAction(webAction);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
  void GWebContentView::deactivateZoomActions()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
  {
3
hgs
parents: 0
diff changeset
   425
    m_actions.value("zoomIn")->setEnabled(false);
hgs
parents: 0
diff changeset
   426
    m_actions.value("zoomOut")->setEnabled(false);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
  }
3
hgs
parents: 0
diff changeset
   428
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
  void GWebContentView::changeZoomAction(qreal zoom){
3
hgs
parents: 0
diff changeset
   430
  #ifndef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   431
    if (!webWidget()) return;
hgs
parents: 0
diff changeset
   432
    if (!(webWidget()->isUserScalable() ) ){
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
        deactivateZoomActions();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    else {
3
hgs
parents: 0
diff changeset
   436
      QAction * zoomOutAction = m_actions.value("zoomOut");
hgs
parents: 0
diff changeset
   437
      QAction * zoomInAction = m_actions.value("zoomIn");
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
      if (zoom <= webWidget()->minimumScale() ) {
3
hgs
parents: 0
diff changeset
   439
         zoomOutAction->setEnabled(false);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
      else {
3
hgs
parents: 0
diff changeset
   442
         zoomOutAction->setEnabled(true);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
      if (zoom >= webWidget()->maximumScale()  ){
3
hgs
parents: 0
diff changeset
   446
         zoomInAction->setEnabled(false);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
      else {
3
hgs
parents: 0
diff changeset
   449
         zoomInAction->setEnabled(true);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    }
3
hgs
parents: 0
diff changeset
   452
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
  void GWebContentView::setZoomFactor(qreal factor){
3
hgs
parents: 0
diff changeset
   456
    if (webWidget())
hgs
parents: 0
diff changeset
   457
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   458
        webWidget()->setScale(factor);
hgs
parents: 0
diff changeset
   459
#else
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
        webWidget()->setZoomFactor(factor);
3
hgs
parents: 0
diff changeset
   461
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
3
hgs
parents: 0
diff changeset
   464
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   465
QGraphicsWidget* GWebContentView::webWidgetConst()  {
hgs
parents: 0
diff changeset
   466
    return m_widget;
hgs
parents: 0
diff changeset
   467
}
hgs
parents: 0
diff changeset
   468
hgs
parents: 0
diff changeset
   469
void GWebContentView::setZoomActions(bool enableZoomIn, bool enableZoomOut)
hgs
parents: 0
diff changeset
   470
{
hgs
parents: 0
diff changeset
   471
    m_actions.value("zoomIn")->setEnabled(enableZoomIn);
hgs
parents: 0
diff changeset
   472
    m_actions.value("zoomOut")->setEnabled(enableZoomOut);
hgs
parents: 0
diff changeset
   473
}
hgs
parents: 0
diff changeset
   474
  qreal GWebContentView::getZoomFactor(){
hgs
parents: 0
diff changeset
   475
    return webWidgetConst() ? webWidgetConst()->scale() : 0.0;
hgs
parents: 0
diff changeset
   476
  }
hgs
parents: 0
diff changeset
   477
hgs
parents: 0
diff changeset
   478
#else
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
  qreal GWebContentView::getZoomFactor() const {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
    return webWidgetConst() ? webWidgetConst()->zoomFactor() : 0.0;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
  }
3
hgs
parents: 0
diff changeset
   482
#endif
hgs
parents: 0
diff changeset
   483
  
hgs
parents: 0
diff changeset
   484
void GWebContentView::activate() {
hgs
parents: 0
diff changeset
   485
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   486
    WRT::WrtBrowserContainer* newPage = WebPageController::getSingleton()->currentPage();
hgs
parents: 0
diff changeset
   487
    changeContentViewZoomInfo(newPage);
hgs
parents: 0
diff changeset
   488
#endif
hgs
parents: 0
diff changeset
   489
    ControllableViewBase::activate();
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
  void GWebContentView::deactivate() {
3
hgs
parents: 0
diff changeset
   493
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   494
    if (!currentPageIsSuperPage()) {
hgs
parents: 0
diff changeset
   495
        WRT::WrtBrowserContainer* currentPage = WebPageController::getSingleton()->currentPage();
hgs
parents: 0
diff changeset
   496
        currentPage->setPageZoomMetaData(m_widget->currentPageInfo());
hgs
parents: 0
diff changeset
   497
    }
hgs
parents: 0
diff changeset
   498
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
      ControllableViewBase::deactivate();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
//  static void appendAction(QWebPage* page, QList<QAction*> &list, enum QWebPage::WebAction webAction, const QString &name) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
//      QAction *action = page->action(webAction);
3
hgs
parents: 0
diff changeset
   504
//      if (action) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
//          action->setObjectName(name);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
//          list.append(action);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
//      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
//  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
  /*!
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    Return the list of public QActions most relevant to the view's current context.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    @return  List of public actions
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
  */
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
  QList<QAction *> GWebContentView::getContext()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
      // Get some of the actions from the page (there are many more available) and build a list
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
      // list of them.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
      QList<QAction*> actions;
3
hgs
parents: 0
diff changeset
   520
      QAction * action = m_actions.value("zoomIn");
hgs
parents: 0
diff changeset
   521
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
      /* Add zoomIn and zoomOut actions created earlier*/
3
hgs
parents: 0
diff changeset
   524
      if (action) actions.append(action);
hgs
parents: 0
diff changeset
   525
hgs
parents: 0
diff changeset
   526
      action = m_actions.value("zoomOut");
hgs
parents: 0
diff changeset
   527
      if (action) actions.append(action);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
      return actions;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
  QAction * GWebContentView::getAction(const QString & action)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
  {
3
hgs
parents: 0
diff changeset
   535
    QAction * act = NULL;
hgs
parents: 0
diff changeset
   536
    if (m_actions.contains(action) )
hgs
parents: 0
diff changeset
   537
        act = m_actions.value(action);
hgs
parents: 0
diff changeset
   538
hgs
parents: 0
diff changeset
   539
    if (!act ) {
hgs
parents: 0
diff changeset
   540
        WebPageController * pageController =  WebPageController::getSingleton();
hgs
parents: 0
diff changeset
   541
        if (action == "Back")
hgs
parents: 0
diff changeset
   542
          act = pageController->getActionBack();
hgs
parents: 0
diff changeset
   543
        else if (action == "Forward")
hgs
parents: 0
diff changeset
   544
          act = pageController->getActionForward();
hgs
parents: 0
diff changeset
   545
        else if (action == "Stop")
hgs
parents: 0
diff changeset
   546
          act = pageController->getActionStop();
hgs
parents: 0
diff changeset
   547
        else if (action == "Reload")
hgs
parents: 0
diff changeset
   548
          act = pageController->getActionReload();
hgs
parents: 0
diff changeset
   549
hgs
parents: 0
diff changeset
   550
    }
hgs
parents: 0
diff changeset
   551
    return act;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
  void GWebContentView::scrollViewBy(int dx, int dy)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
      wrtPage()->mainFrame()->scroll(dx, dy);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
  void GWebContentView::scrollViewTo(int x, int y)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
      wrtPage()->mainFrame()->setScrollPosition(QPoint(x, y));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
  void GWebContentView::showMessageBox(WRT::MessageBoxProxy* proxy)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
  /*
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
      QMessageBox msgBox(this);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
      msgBox.setText(proxy->m_text);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
      msgBox.setInformativeText(proxy->m_informativeText);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
      msgBox.setDetailedText(proxy->m_detailedText);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
      msgBox.setStandardButtons(proxy->m_buttons);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
      msgBox.setDefaultButton(proxy->m_defaultButton);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
      msgBox.setIcon(proxy->m_icon);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
      int ret = msgBox.exec();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
      */
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
      QString displayText = proxy->m_text + QLatin1String("\n") + QLatin1String("\n")+ proxy->m_detailedText + QLatin1String("\n") + QLatin1String("\n") + proxy->m_informativeText;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
      int ret = QMessageBox::warning(0/* TODO: find appropriate widget if required or just remove this widget()*/,
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
                                     proxy->m_text, displayText, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
      proxy->onMessageBoxResponse(ret);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
  void GWebContentView::loadUrlToCurrentPage(const QString & url)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
      WRT::WrtBrowserContainer * activePage = WebPageController::getSingleton()->currentPage();
12
hgs
parents: 9
diff changeset
   586
      QString bookmark_url = url;
hgs
parents: 9
diff changeset
   587
      if(!bookmark_url.contains(KBOOKMARKURLFILESLASH)){
hgs
parents: 9
diff changeset
   588
         if(bookmark_url.contains(KBOOKMARKURLFILE))
hgs
parents: 9
diff changeset
   589
            bookmark_url.replace(QString(KBOOKMARKURLFILE), QString(KBOOKMARKURLFILESLASH));
hgs
parents: 9
diff changeset
   590
      }
hgs
parents: 9
diff changeset
   591
      //--DeCoding URL for DoubleQuote and BackSlash--
hgs
parents: 9
diff changeset
   592
      if (bookmark_url.contains(KENCODEDBACKSLASH, Qt::CaseInsensitive))
hgs
parents: 9
diff changeset
   593
          bookmark_url.replace(QString(KENCODEDBACKSLASH), QString("\\"));
hgs
parents: 9
diff changeset
   594
      if (bookmark_url.contains(KENCODEDDOUBLEQUOTE, Qt::CaseInsensitive))
hgs
parents: 9
diff changeset
   595
          bookmark_url.replace(QString(KENCODEDDOUBLEQUOTE), QString("\""));
hgs
parents: 9
diff changeset
   596
      
3
hgs
parents: 0
diff changeset
   597
      if (activePage) {
12
hgs
parents: 9
diff changeset
   598
          activePage->mainFrame()->load(bookmark_url);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
  QWebPage *GWebContentView::currentPage() {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
      WRT::WrtBrowserContainer * activePage = WebPageController::getSingleton()->currentPage();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
      return activePage;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
  int GWebContentView::contentWidth()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
    return currentPage()->mainFrame()->contentsSize().width();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
  int GWebContentView::contentHeight()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
    return currentPage()->mainFrame()->contentsSize().height();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
  void GWebContentView::stop()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
    webWidget()->stop();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
  void GWebContentView::back()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
    webWidget()->back();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
  void GWebContentView::forward()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
    webWidget()->forward();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
  void GWebContentView::reload()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
    webWidget()->reload();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
  int GWebContentView::scrollX()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
    return currentPage()->mainFrame()->scrollPosition().x();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
  int GWebContentView::scrollY()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
    return currentPage()->mainFrame()->scrollPosition().y();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
  void GWebContentView::zoom(bool in)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
    m_zoomIn = in;
3
hgs
parents: 0
diff changeset
   650
    if (!m_timeLine) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
      m_timeLine = new QTimeLine();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
      connect(m_timeLine, SIGNAL(valueChanged(qreal)),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
        this, SLOT(updateZoom(qreal)));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
    else {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
      m_timeLine->stop();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
    m_timeLine->start();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
  void GWebContentView::toggleZoom(){
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
    zoom(!m_zoomIn);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
  void GWebContentView::stopZoom() {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
    m_timeLine->stop();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
  void GWebContentView::updateZoom(qreal delta){
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
    Q_UNUSED(delta)
3
hgs
parents: 0
diff changeset
   670
#ifndef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   671
    if (m_zoomIn)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
      zoomBy(0.1);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
    else
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
      zoomBy(-0.1);
3
hgs
parents: 0
diff changeset
   675
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
  void GWebContentView::onUrlChanged(const QUrl& url)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
    emit urlChanged(url.toString());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
    //NB: Brief hack
3
hgs
parents: 0
diff changeset
   682
    if (url.scheme()=="https")
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
      emit secureConnection(true);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
    else
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
      emit secureConnection(false);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
3
hgs
parents: 0
diff changeset
   688
  GSuperWebPage *GWebContentView::createSuperPage(const QString &name, bool persist) {
hgs
parents: 0
diff changeset
   689
    GSuperWebPage *page = 0;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
    PageMap::iterator it = m_superPages.find(name);
3
hgs
parents: 0
diff changeset
   691
    // If page doesn't exist create a new one.
hgs
parents: 0
diff changeset
   692
    if (it == m_superPages.end()) {
hgs
parents: 0
diff changeset
   693
hgs
parents: 0
diff changeset
   694
      if (persist || !m_sharedPage){
hgs
parents: 0
diff changeset
   695
          if (persist)
hgs
parents: 0
diff changeset
   696
              //Implicitly creates a new QWebPage that is owned by the superpage object
hgs
parents: 0
diff changeset
   697
              page = new GSuperWebPage(0, chrome());
hgs
parents: 0
diff changeset
   698
hgs
parents: 0
diff changeset
   699
          else {
hgs
parents: 0
diff changeset
   700
              //Create a shared QWebPage that is owned by this view
hgs
parents: 0
diff changeset
   701
              m_sharedPage = new WebPageWrapper(this, "Superpage javascript error");
hgs
parents: 0
diff changeset
   702
              page = new GSuperWebPage(m_sharedPage, chrome());
hgs
parents: 0
diff changeset
   703
          }
hgs
parents: 0
diff changeset
   704
          //No scroll bars
hgs
parents: 0
diff changeset
   705
          page->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
hgs
parents: 0
diff changeset
   706
          page->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
hgs
parents: 0
diff changeset
   707
          //No history for super pages
hgs
parents: 0
diff changeset
   708
          page->page()->history()->setMaximumItemCount(0);
hgs
parents: 0
diff changeset
   709
          //Limit page cache usage by super pages
hgs
parents: 0
diff changeset
   710
hgs
parents: 0
diff changeset
   711
          //NB: needed?
hgs
parents: 0
diff changeset
   712
          QPalette viewPalette = widget()->palette();
hgs
parents: 0
diff changeset
   713
          viewPalette.setBrush(QPalette::Base, Qt::white);
hgs
parents: 0
diff changeset
   714
          page->page()->setPalette(viewPalette);
hgs
parents: 0
diff changeset
   715
      } else {
hgs
parents: 0
diff changeset
   716
          //Reuse the shared QWebPage
hgs
parents: 0
diff changeset
   717
          page = new GSuperWebPage(m_sharedPage, chrome());
hgs
parents: 0
diff changeset
   718
      }
hgs
parents: 0
diff changeset
   719
      //Export the superpage to JS
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
      page->setParent(jsObject());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
      page->setObjectName(name);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
      // Add it to the superpage list.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
      m_superPages[name] = page;
3
hgs
parents: 0
diff changeset
   724
      if (m_superPages.count() == 1) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
        // This is the only superpage, make it current.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
        m_currentSuperPage = m_superPages.find(name);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
    else {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
      qDebug() << "GWebContentView::createPage: page already exists: " << name;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
    }
3
hgs
parents: 0
diff changeset
   732
    //Create a controllable view onto the super page so that it can be controlled by the view controller.
hgs
parents: 0
diff changeset
   733
    m_chrome->addView(new SuperPageView(this, page, name));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
    return page;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
  }
3
hgs
parents: 0
diff changeset
   736
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
  void GWebContentView::destroySuperPage(const QString &name) {
3
hgs
parents: 0
diff changeset
   738
    if (!m_superPages.contains(name)) return;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
3
hgs
parents: 0
diff changeset
   740
    GSuperWebPage *page = m_superPages.take(name);
hgs
parents: 0
diff changeset
   741
    //This will destroy any QWebPage owned by the super page. The shared page is not
hgs
parents: 0
diff changeset
   742
    //owned by the super page and will be deleted when the GWebContentView is deleted.
hgs
parents: 0
diff changeset
   743
    if (page){
hgs
parents: 0
diff changeset
   744
        delete page;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
3
hgs
parents: 0
diff changeset
   748
  bool GWebContentView::setCurrentSuperPage(const QString &name) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
    PageMap::iterator it = m_superPages.find(name);
3
hgs
parents: 0
diff changeset
   750
    if (it != m_superPages.end()) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
      m_currentSuperPage = it;
3
hgs
parents: 0
diff changeset
   752
      return true;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
    else {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
      qDebug() << "GWebContentView::setCurrentSuperPage: not found: " << name;
3
hgs
parents: 0
diff changeset
   756
      return false;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
  }
3
hgs
parents: 0
diff changeset
   759
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
  bool GWebContentView::isSuperPage(const QString &name){
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   761
      PageMap::iterator it = m_superPages.find(name);
3
hgs
parents: 0
diff changeset
   762
      if (it != m_superPages.end()) {
hgs
parents: 0
diff changeset
   763
        return true;
hgs
parents: 0
diff changeset
   764
      }
hgs
parents: 0
diff changeset
   765
      qDebug() << "GWebContentView::superPage: not found: " << name;
hgs
parents: 0
diff changeset
   766
      return false;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
 }
3
hgs
parents: 0
diff changeset
   768
hgs
parents: 0
diff changeset
   769
hgs
parents: 0
diff changeset
   770
  GSuperWebPage * GWebContentView::superPage(const QString &name) {
hgs
parents: 0
diff changeset
   771
      PageMap::iterator it = m_superPages.find(name);
hgs
parents: 0
diff changeset
   772
      if (it != m_superPages.end()) {
hgs
parents: 0
diff changeset
   773
          return it.value();
hgs
parents: 0
diff changeset
   774
      }
hgs
parents: 0
diff changeset
   775
      qDebug() << "GWebContentView::superPage: not found: " << name;
hgs
parents: 0
diff changeset
   776
      return 0;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
  }
3
hgs
parents: 0
diff changeset
   778
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
  void GWebContentView::showSuperPage(const QString &name) {
3
hgs
parents: 0
diff changeset
   780
      if(isSuperPage(name)) {
hgs
parents: 0
diff changeset
   781
          if(currentPageIsSuperPage()) {
hgs
parents: 0
diff changeset
   782
              currentSuperPage()->onHidden();
hgs
parents: 0
diff changeset
   783
          }
hgs
parents: 0
diff changeset
   784
hgs
parents: 0
diff changeset
   785
          setCurrentSuperPage(name);
hgs
parents: 0
diff changeset
   786
          m_currentPageIsSuperPage = true;
hgs
parents: 0
diff changeset
   787
#ifndef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   788
          webWidget()->setPage(currentSuperPage()->page());
hgs
parents: 0
diff changeset
   789
          m_touchNavigation->setPage(webWidget()->page());
hgs
parents: 0
diff changeset
   790
          m_touchNavigation->setWantSlideViewCalls(false);
hgs
parents: 0
diff changeset
   791
          webWidget()->page()->setPreferredContentsSize(webWidget()->size().toSize());
hgs
parents: 0
diff changeset
   792
#else
hgs
parents: 0
diff changeset
   793
          WRT::WrtBrowserContainer *pg = WebPageController::getSingleton()->currentPage();
hgs
parents: 0
diff changeset
   794
          pg->setPageZoomMetaData(m_widget->currentPageInfo());
hgs
parents: 0
diff changeset
   795
          m_widget->setPage(currentSuperPage()->page());
hgs
parents: 0
diff changeset
   796
          m_widget->showPage(true);
hgs
parents: 0
diff changeset
   797
#endif  
hgs
parents: 0
diff changeset
   798
          emit superPageShown(name);
hgs
parents: 0
diff changeset
   799
          currentSuperPage()->onShown();
hgs
parents: 0
diff changeset
   800
      }
hgs
parents: 0
diff changeset
   801
      else {
hgs
parents: 0
diff changeset
   802
          qDebug() << "GWebContentView::showSuperPage: error, not found: " << name;
hgs
parents: 0
diff changeset
   803
      }
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
  void GWebContentView::showNormalPage() {
3
hgs
parents: 0
diff changeset
   807
    if (webWidget()) {
hgs
parents: 0
diff changeset
   808
      //TODO: Further testing is needed to show if the following is a net benefit.
hgs
parents: 0
diff changeset
   809
      if (currentPageIsSuperPage()) {
hgs
parents: 0
diff changeset
   810
          if(currentSuperPage()->page() == m_sharedPage){
hgs
parents: 0
diff changeset
   811
              //Clear contents of shared page to free resources. This should save
hgs
parents: 0
diff changeset
   812
              //memory for big pages, but at the performance cost of loading an empty page.
hgs
parents: 0
diff changeset
   813
              //An alternative is to delete the shared page every time and reallocate it when
hgs
parents: 0
diff changeset
   814
              //a super page is loaded.
hgs
parents: 0
diff changeset
   815
              currentSuperPage()->page()->mainFrame()->setHtml(QString());
hgs
parents: 0
diff changeset
   816
          }
hgs
parents: 0
diff changeset
   817
hgs
parents: 0
diff changeset
   818
          currentSuperPage()->onHidden();
hgs
parents: 0
diff changeset
   819
          m_currentPageIsSuperPage =false;
hgs
parents: 0
diff changeset
   820
      }
9
hgs
parents: 3
diff changeset
   821
#ifndef BEDROCK_TILED_BACKING_STORE
hgs
parents: 3
diff changeset
   822
    webWidget()->showNormalPage();
hgs
parents: 3
diff changeset
   823
    webWidget()->setViewportSize();
hgs
parents: 3
diff changeset
   824
    m_touchNavigation->setPage(currentPage());
hgs
parents: 3
diff changeset
   825
    m_touchNavigation->setWantSlideViewCalls(true);
hgs
parents: 3
diff changeset
   826
#else
hgs
parents: 3
diff changeset
   827
    m_widget->showPage(false);
hgs
parents: 3
diff changeset
   828
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   829
    }
12
hgs
parents: 9
diff changeset
   830
	WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage();
hgs
parents: 9
diff changeset
   831
			if(currPage){
hgs
parents: 9
diff changeset
   832
			  webWidget()->initializeViewportParams();
hgs
parents: 9
diff changeset
   833
			  webWidget()->setZoomFactor(currPage->pageZoomMetaData().zoomValue);
hgs
parents: 9
diff changeset
   834
			}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
  }
3
hgs
parents: 0
diff changeset
   836
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
  QObjectList GWebContentView::getSuperPages() {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
    QObjectList *result = new QObjectList;
3
hgs
parents: 0
diff changeset
   839
    foreach(GVA::GSuperWebPage *page, m_superPages) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
      result->append(page);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
    // TO DO: Need to add result to JS engine so it can be cleaned up.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
    return *result;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
  bool GWebContentView::currentPageIsSuperPage() const {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
    //qDebug() << "GWebContentView::currentPageIsSuperPage: " << webWidget()->page();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
    return m_currentPageIsSuperPage;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
  void GWebContentView::onLoadStarted()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
    //qDebug() << "GWebContentView::onLoadStarted: " << QTime::currentTime();
3
hgs
parents: 0
diff changeset
   854
#if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
      m_widget->onLoadStarted();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
#endif
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
    emit loadStarted();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
  void GWebContentView::onLoadFinished(bool ok)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   861
  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
    //qDebug() << "GWebContentView::onLoadFinished: " << QTime::currentTime();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
    emit loadFinished(ok);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
    //NB: page manager functions really
3
hgs
parents: 0
diff changeset
   865
    if (!m_backEnabled && currentPage()->history()->canGoBack()){
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
      m_backEnabled = true;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
      emit backEnabled(true);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
    else if (m_backEnabled && !currentPage()->history()->canGoBack()){
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
      m_backEnabled = false;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
      emit backEnabled(false);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
    }
3
hgs
parents: 0
diff changeset
   873
    if (!m_forwardEnabled && currentPage()->history()->canGoForward()){
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   874
      m_forwardEnabled = true;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
      emit forwardEnabled(true);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
    else if (m_forwardEnabled && !currentPage()->history()->canGoForward()){
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
      m_forwardEnabled = false;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
      emit forwardEnabled(false);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
    }
3
hgs
parents: 0
diff changeset
   881
12
hgs
parents: 9
diff changeset
   882
    // Set focus to the Web View so that text boxes have the focus (BR-994) if user is not editing the
hgs
parents: 9
diff changeset
   883
    // url field
hgs
parents: 9
diff changeset
   884
    if (!WebPageController::getSingleton()->editMode())
hgs
parents: 9
diff changeset
   885
        m_widget->setFocus();
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
#if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
    m_widget->onLoadFinished();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
#endif
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   890
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   891
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
  void GWebContentView::dump() {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
    qDebug() << "-------------";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   894
    qDebug() << "GWebContentView::dump: " << this;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
    qDebug() << "\tcurrent page=: " << currentPage() << " title=" << currentPage()->mainFrame()->title();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
    qDebug() << "\tcurrent superpage=: " << currentSuperPage();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
    qDebug() << "\tsuperpage count=: " << m_superPages.count();
3
hgs
parents: 0
diff changeset
   898
    foreach(GVA::GSuperWebPage *page, m_superPages) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
      page->dump();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
    qDebug() << "GWebContentView::dump: finished";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
    qDebug() << "-------------";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   903
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
//  ControllableView* GWebContentView::createNew(QWidget *parent)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
//  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
//      QWebPage* page = BrowserPageFactory::openBrowserPage();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   908
//      return new GWebContentView(page, parent);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
//  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
  void GWebContentView::pageCreated(WRT::WrtBrowserContainer* newPage) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
      /* save the page snapshot before changing the current page to the new page*/
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
      WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage();
3
hgs
parents: 0
diff changeset
   916
      if (currPage) {
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
          QWebHistoryItem item = currPage->history()->currentItem();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
          currPage->savePageDataToHistoryItem(currPage->mainFrame(), &item);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
      // When new windows are created from window view, as the content is empty, we should disable
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
      // zoom actions. Set the user-scalable to false and also init the other zoom params
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
      // so that even if we change to windows view again without loading a page we are safe.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
      // In the code-driven window usecase, this will be overwritten when the page is loaded and setViewportSize is invoked
3
hgs
parents: 0
diff changeset
   925
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   926
      newPage->setPageZoomMetaData(webWidget()->defaultZoomData());
3
hgs
parents: 0
diff changeset
   927
#else
hgs
parents: 0
diff changeset
   928
	newPage->setPageZoomMetaData(m_widget->defaultZoomData());
hgs
parents: 0
diff changeset
   929
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
      /* Set the new page as the current page */
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
      WebPageController::getSingleton()->setCurrentPage(newPage);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   932
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   933
      /* Set the web widget- this one is responsible for webnavigation etc */
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   934
      newPage->setWebWidget(webWidget());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   935
3
hgs
parents: 0
diff changeset
   936
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   937
      //connect new page main frame's initialLayoutCompleted with WebContentWidget' setViewportSize SLOT
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   938
      connect(newPage->mainFrame(), SIGNAL(initialLayoutCompleted()), webWidget(), SLOT(setViewportSize()));
3
hgs
parents: 0
diff changeset
   939
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   940
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   941
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   942
  void GWebContentView::updateWebPage(WRT::WrtBrowserContainer* pg)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   943
  {
3
hgs
parents: 0
diff changeset
   944
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   945
      QGraphicsWebView* w = webWidget();
hgs
parents: 0
diff changeset
   946
#else
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
      GWebContentViewWidget* w = webWidget();
3
hgs
parents: 0
diff changeset
   948
#endif
hgs
parents: 0
diff changeset
   949
	  
hgs
parents: 0
diff changeset
   950
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   951
      w->setPage(pg);
3
hgs
parents: 0
diff changeset
   952
#else	  
hgs
parents: 0
diff changeset
   953
	  m_widget->setPage(pg);
hgs
parents: 0
diff changeset
   954
#endif
hgs
parents: 0
diff changeset
   955
      if (pg)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   956
      {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
          pg->setWebWidget(w);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
3
hgs
parents: 0
diff changeset
   959
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
          // Change navigation also to the current page
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
          m_touchNavigation->setPage(pg);
3
hgs
parents: 0
diff changeset
   962
          m_touchNavigation->setWantSlideViewCalls(true);
hgs
parents: 0
diff changeset
   963
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   965
      }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   966
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   967
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
  void GWebContentView::pageChanged(WRT::WrtBrowserContainer* oldPage, WRT::WrtBrowserContainer* newPage) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   969
      Q_UNUSED(oldPage)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   970
      updateWebPage(newPage);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   971
3
hgs
parents: 0
diff changeset
   972
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   973
      // Set new page zoom info
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   974
      changeContentViewZoomInfo(newPage);
3
hgs
parents: 0
diff changeset
   975
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   976
  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   977
3
hgs
parents: 0
diff changeset
   978
#ifdef BEDROCK_TILED_BACKING_STORE
hgs
parents: 0
diff changeset
   979
  void GWebContentView::handleContextEventObject(QWebHitTestResult* eventTarget)
hgs
parents: 0
diff changeset
   980
  {
hgs
parents: 0
diff changeset
   981
      WebViewEventContext context(type(), *eventTarget);
hgs
parents: 0
diff changeset
   982
      if (currentPageIsSuperPage()) {
hgs
parents: 0
diff changeset
   983
          // Let the superpage handle the event.
hgs
parents: 0
diff changeset
   984
          currentSuperPage()->onContextEvent(&context);
hgs
parents: 0
diff changeset
   985
      }
hgs
parents: 0
diff changeset
   986
      else {
hgs
parents: 0
diff changeset
   987
          // Send the event directly.
hgs
parents: 0
diff changeset
   988
          emit contextEvent(&context);
hgs
parents: 0
diff changeset
   989
      }
hgs
parents: 0
diff changeset
   990
  }
hgs
parents: 0
diff changeset
   991
void GWebContentView::handleViewScrolled(QPoint& scrollPos, QPoint& delta)
hgs
parents: 0
diff changeset
   992
{
9
hgs
parents: 3
diff changeset
   993
    if (delta.manhattanLength() && (delta.y() > 0  || scrollPos.y() + delta.y() <= 40) 
hgs
parents: 3
diff changeset
   994
        && !currentPageIsSuperPage())
3
hgs
parents: 0
diff changeset
   995
        m_chrome->layout()->slideView(-delta.y());
9
hgs
parents: 3
diff changeset
   996
    
hgs
parents: 3
diff changeset
   997
    emit startingPanGesture(1);
3
hgs
parents: 0
diff changeset
   998
}
hgs
parents: 0
diff changeset
   999
hgs
parents: 0
diff changeset
  1000
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1001
  void GWebContentView::changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage){
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1002
     // Copy the new page zoom info into cv
3
hgs
parents: 0
diff changeset
  1003
#ifndef BEDROCK_TILED_BACKING_STORE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1004
     webWidget()->setPageZoomMetaData(newPage->pageZoomMetaData());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1005
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1006
     if (webWidget()->isUserScalable()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1007
         webWidget()->setZoomFactor(newPage->mainFrame()->zoomFactor());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1008
     }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1009
     else {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1010
         // Need to call setPageZoomFactor instead of setZoomFactor because setZoomFactor
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1011
         // will not do anything if user-scalable is false. But we need to
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1012
         // ensure that the correct zoom factor is applied as there is a possibility
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1013
         // that we might have been on another page earlier
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1014
         webWidget()->setPageZoomFactor(newPage->mainFrame()->zoomFactor());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1015
      }
3
hgs
parents: 0
diff changeset
  1016
#else
hgs
parents: 0
diff changeset
  1017
	 m_widget->setCurrentPageInfo(newPage->pageZoomMetaData());
hgs
parents: 0
diff changeset
  1018
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1019
  }
3
hgs
parents: 0
diff changeset
  1020
hgs
parents: 0
diff changeset
  1021
  void GWebContentView::setJSObject(const QString &objectName) {
hgs
parents: 0
diff changeset
  1022
      m_jsObject = new GWebContentViewJSObject(this, m_chrome->page()->mainFrame(), objectName);
hgs
parents: 0
diff changeset
  1023
  }
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1024
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1025
3
hgs
parents: 0
diff changeset
  1026
  bool GWebContentView::enabled() const {
hgs
parents: 0
diff changeset
  1027
      return m_enabled;
hgs
parents: 0
diff changeset
  1028
  }
hgs
parents: 0
diff changeset
  1029
hgs
parents: 0
diff changeset
  1030
  void GWebContentView::setEnabled(bool value) {
hgs
parents: 0
diff changeset
  1031
      if(m_enabled == value)
hgs
parents: 0
diff changeset
  1032
          return;
hgs
parents: 0
diff changeset
  1033
hgs
parents: 0
diff changeset
  1034
      m_enabled = value;
hgs
parents: 0
diff changeset
  1035
      widget()->setEnabled(value);
hgs
parents: 0
diff changeset
  1036
      widget()->update();
hgs
parents: 0
diff changeset
  1037
  }
12
hgs
parents: 9
diff changeset
  1038
  void GWebContentView::setSavedZoomValueInView(qreal zoomValue){
hgs
parents: 9
diff changeset
  1039
	  m_savedZoomValueInView = zoomValue;
hgs
parents: 9
diff changeset
  1040
  }
hgs
parents: 9
diff changeset
  1041
  
hgs
parents: 9
diff changeset
  1042
  qreal GWebContentView::getSavedZoomValueInView() const{
hgs
parents: 9
diff changeset
  1043
      return m_savedZoomValueInView;
hgs
parents: 9
diff changeset
  1044
  }
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1045
} // end of namespace GVA
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1046
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1047