ginebra2/UrlSearchSnippet.cpp
author hgs
Fri, 15 Oct 2010 17:30:59 -0400
changeset 16 3c88a81ff781
parent 14 6aeb7a756187
permissions -rw-r--r--
201041
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
*
3
hgs
parents: 0
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 "UrlSearchSnippet.h"
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include "Utilities.h"
16
hgs
parents: 14
diff changeset
    24
#include "UiUtil.h"
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include "ChromeRenderer.h"
3
hgs
parents: 0
diff changeset
    26
#include "ChromeLayout.h"
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "ChromeWidget.h"
3
hgs
parents: 0
diff changeset
    28
#include "PageSnippet.h"
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "ViewController.h"
3
hgs
parents: 0
diff changeset
    30
#include "ViewStack.h"
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "WebChromeSnippet.h"
3
hgs
parents: 0
diff changeset
    32
#include "LoadController.h"
hgs
parents: 0
diff changeset
    33
#include "webpagecontroller.h"
hgs
parents: 0
diff changeset
    34
#include "GWebContentView.h"
hgs
parents: 0
diff changeset
    35
#include "WindowFlowView.h"
16
hgs
parents: 14
diff changeset
    36
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
    37
#include "secureuicontroller.h"
hgs
parents: 14
diff changeset
    38
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
12
hgs
parents: 9
diff changeset
    40
3
hgs
parents: 0
diff changeset
    41
#include <QWebHistoryItem>
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
namespace GVA {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
16
hgs
parents: 14
diff changeset
    45
#define GO_BUTTON_ICON ":/urlsearch/go_btn.png"
hgs
parents: 14
diff changeset
    46
#define STOP_BUTTON_ICON ":/urlsearch/stop_btn.png"
hgs
parents: 14
diff changeset
    47
#define SPECIFIC_BUTTON_ICON ":/urlsearch/com.svg"
9
hgs
parents: 3
diff changeset
    48
#define SPECIFIC_BUTTON_STRING ".com"
3
hgs
parents: 0
diff changeset
    49
#define BETWEEN_ENTRY_AND_BUTTON_SPACE 4
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
16
hgs
parents: 14
diff changeset
    51
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
    52
#define URL_TITLE_IND_BUTTON_ICON ":/urlsearch/url_title_ind_btn.png"
hgs
parents: 14
diff changeset
    53
#define URL_TITLE_IND_SECURE_BUTTON_ICON ":/urlsearch/url_title_ind_btn_secure.png"
hgs
parents: 14
diff changeset
    54
#endif
hgs
parents: 14
diff changeset
    55
12
hgs
parents: 9
diff changeset
    56
static const QString KBookmarkHistoryViewName = "BookmarkHistoryView";
hgs
parents: 9
diff changeset
    57
static const QString KBookmarkTreeViewName = "BookmarkTreeView";
hgs
parents: 9
diff changeset
    58
static const QString KWindowViewName = "WindowView";
hgs
parents: 9
diff changeset
    59
static const QString KSettingsViewName = "SettingsView";
hgs
parents: 9
diff changeset
    60
hgs
parents: 9
diff changeset
    61
//#define VBORDER_GRADIENT_START "#292929"
hgs
parents: 9
diff changeset
    62
//#define VBORDER_GRADIENT_STOP "#535354"
hgs
parents: 9
diff changeset
    63
//#define VBORDER_GRADIENT_END "#020202"
hgs
parents: 9
diff changeset
    64
3
hgs
parents: 0
diff changeset
    65
GUrlSearchItem::GUrlSearchItem(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
: NativeChromeItem(snippet, parent)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
, m_chrome(chrome)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
, m_viewPortWidth(0.0)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
, m_viewPortHeight(0.0)
3
hgs
parents: 0
diff changeset
    70
, m_pendingClearCalls(0)
hgs
parents: 0
diff changeset
    71
, m_backFromNewWinTrans(false)
hgs
parents: 0
diff changeset
    72
, m_justFocusIn(false)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
    // Extract style information from element CSS.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
    // For border-related properties, we constrain all values (top, left, etc.)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
    // to be the same.  These can be set using the css shorthand (e.g. padding:10px),
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    // but the computed css style will be for the four primitive values (padding-top,
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    // padding-left) etc, which will all be equal.  Hence we just use one of the
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    // computed primitive values (top) to represent the common value.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
12
hgs
parents: 9
diff changeset
    82
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
    QWebElement we = m_snippet->element();
12
hgs
parents: 9
diff changeset
    84
 
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    QString cssPadding = we.styleProperty("padding-top", QWebElement::ComputedStyle);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    m_padding = cssPadding.remove("px").toInt();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    QString cssBorder = we.styleProperty("border-top-width", QWebElement::ComputedStyle);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    m_border = cssBorder.remove("px").toInt();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
3
hgs
parents: 0
diff changeset
    91
    // Create the view port widget
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    m_viewPort = new QGraphicsWidget(this);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    m_viewPort->setFlags(QGraphicsItem::ItemClipsChildrenToShape);
12
hgs
parents: 9
diff changeset
    94
    
16
hgs
parents: 14
diff changeset
    95
    createEditor();
hgs
parents: 14
diff changeset
    96
    createIcons();
hgs
parents: 14
diff changeset
    97
    
3
hgs
parents: 0
diff changeset
    98
    // Update state as soon as chrome completes loading.
hgs
parents: 0
diff changeset
    99
    safe_connect(m_chrome, SIGNAL(chromeComplete()),
hgs
parents: 0
diff changeset
   100
            this, SLOT(onChromeComplete()));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
12
hgs
parents: 9
diff changeset
   102
#ifndef BROWSER_LAYOUT_TENONE
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
    // Monitor resize events.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    safe_connect(m_chrome->renderer(), SIGNAL(chromeResized()),
12
hgs
parents: 9
diff changeset
   105
            this, SLOT(resize())); 
hgs
parents: 9
diff changeset
   106
#endif
3
hgs
parents: 0
diff changeset
   107
hgs
parents: 0
diff changeset
   108
 /*   safe_connect(ViewStack::getSingleton(), SIGNAL(currentViewChanged()),
hgs
parents: 0
diff changeset
   109
            this, SLOT(viewChanged()));*/
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
3
hgs
parents: 0
diff changeset
   112
GUrlSearchItem::~GUrlSearchItem()
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
{
12
hgs
parents: 9
diff changeset
   114
0
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
3
hgs
parents: 0
diff changeset
   117
hgs
parents: 0
diff changeset
   118
void GUrlSearchItem::resizeEvent(QGraphicsSceneResizeEvent * event)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
{
3
hgs
parents: 0
diff changeset
   120
    QSizeF size = event->newSize();
hgs
parents: 0
diff changeset
   121
hgs
parents: 0
diff changeset
   122
    m_viewPortWidth  = size.width()  - m_padding * 2;
hgs
parents: 0
diff changeset
   123
    m_viewPortHeight = size.height() - m_padding * 2;
hgs
parents: 0
diff changeset
   124
    
hgs
parents: 0
diff changeset
   125
    m_viewPort->setGeometry(
hgs
parents: 0
diff changeset
   126
            m_padding,
hgs
parents: 0
diff changeset
   127
            m_padding,
hgs
parents: 0
diff changeset
   128
            m_viewPortWidth,
hgs
parents: 0
diff changeset
   129
            m_viewPortHeight);
16
hgs
parents: 14
diff changeset
   130
    
hgs
parents: 14
diff changeset
   131
    changeLayout(m_urlSearchBtn->isVisible());
hgs
parents: 14
diff changeset
   132
}
3
hgs
parents: 0
diff changeset
   133
16
hgs
parents: 14
diff changeset
   134
//TODO: Shouldn't have to explicitly set the viewport sizes here
hgs
parents: 14
diff changeset
   135
void GUrlSearchItem::changeLayout(const bool isSearch)
hgs
parents: 14
diff changeset
   136
{
hgs
parents: 14
diff changeset
   137
    
hgs
parents: 14
diff changeset
   138
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   139
    qreal searchBtnWidth = (isSearch) ? m_buttonIconWidth : 0;
hgs
parents: 14
diff changeset
   140
    qreal titleIndBtnWidth = (m_urlTitleIndBtn->isVisible() || m_urlTitleIndSecureBtn->isVisible()) ? m_buttonIconWidth : 0;
hgs
parents: 14
diff changeset
   141
    
hgs
parents: 14
diff changeset
   142
    m_urlTitleIndBtn->setGeometry(0,
hgs
parents: 14
diff changeset
   143
        (m_viewPortHeight - m_buttonIconHeight)/2,
hgs
parents: 14
diff changeset
   144
        titleIndBtnWidth,
hgs
parents: 14
diff changeset
   145
        m_buttonIconHeight);
hgs
parents: 14
diff changeset
   146
    
hgs
parents: 14
diff changeset
   147
    m_urlTitleIndSecureBtn->setGeometry(0,
hgs
parents: 14
diff changeset
   148
        (m_viewPortHeight - m_buttonIconHeight)/2,
hgs
parents: 14
diff changeset
   149
        titleIndBtnWidth,
hgs
parents: 14
diff changeset
   150
        m_buttonIconHeight);
hgs
parents: 14
diff changeset
   151
    
hgs
parents: 14
diff changeset
   152
    // NOTE: removed padding for the x coordinate since too much separation was introduced
hgs
parents: 14
diff changeset
   153
    m_urlSearchBtn->setGeometry(
hgs
parents: 14
diff changeset
   154
        m_viewPortWidth - searchBtnWidth,
hgs
parents: 14
diff changeset
   155
        (m_viewPortHeight - m_buttonIconHeight)/2,
hgs
parents: 14
diff changeset
   156
        searchBtnWidth,
hgs
parents: 14
diff changeset
   157
        m_buttonIconHeight);
hgs
parents: 14
diff changeset
   158
hgs
parents: 14
diff changeset
   159
    m_urlSearchEditor->setRightTextMargin(m_buttonIconWidth);
hgs
parents: 14
diff changeset
   160
    m_urlSearchEditor->setGeometry(titleIndBtnWidth,
hgs
parents: 14
diff changeset
   161
            0,
hgs
parents: 14
diff changeset
   162
            m_viewPortWidth - titleIndBtnWidth,
hgs
parents: 14
diff changeset
   163
            m_viewPortHeight);
hgs
parents: 14
diff changeset
   164
    
hgs
parents: 14
diff changeset
   165
#else
hgs
parents: 14
diff changeset
   166
    qreal searchBtnWidth = m_buttonIconWidth;
3
hgs
parents: 0
diff changeset
   167
hgs
parents: 0
diff changeset
   168
    m_urlSearchBtn->setGeometry(
16
hgs
parents: 14
diff changeset
   169
        m_viewPortWidth - searchBtnWidth - m_padding/2,
hgs
parents: 14
diff changeset
   170
        (m_viewPortHeight - m_buttonIconHeight)/2,
hgs
parents: 14
diff changeset
   171
        searchBtnWidth,
hgs
parents: 14
diff changeset
   172
        m_buttonIconHeight);
hgs
parents: 14
diff changeset
   173
    
3
hgs
parents: 0
diff changeset
   174
    m_urlSearchEditor->setGeometry(0,
hgs
parents: 0
diff changeset
   175
            0,
hgs
parents: 0
diff changeset
   176
            m_viewPortWidth,
hgs
parents: 0
diff changeset
   177
            m_viewPortHeight);
16
hgs
parents: 14
diff changeset
   178
    
hgs
parents: 14
diff changeset
   179
#endif
hgs
parents: 14
diff changeset
   180
    
hgs
parents: 14
diff changeset
   181
}
hgs
parents: 14
diff changeset
   182
hgs
parents: 14
diff changeset
   183
void GUrlSearchItem::onContextEvent(bool isContentSelected)
hgs
parents: 14
diff changeset
   184
{
hgs
parents: 14
diff changeset
   185
    // dismiss suggest snippet
hgs
parents: 14
diff changeset
   186
    PageSnippet * suggestSnippet = qobject_cast<PageSnippet*>(m_chrome->getSnippet("SuggestsChromeId"));
hgs
parents: 14
diff changeset
   187
    if (suggestSnippet) {
hgs
parents: 14
diff changeset
   188
        QString cmd = "searchSuggests.hideSuggests();";
hgs
parents: 14
diff changeset
   189
        suggestSnippet->evaluateJavaScript(cmd);
hgs
parents: 14
diff changeset
   190
    }
hgs
parents: 14
diff changeset
   191
    emit contextEvent(isContentSelected);
hgs
parents: 14
diff changeset
   192
}
hgs
parents: 14
diff changeset
   193
hgs
parents: 14
diff changeset
   194
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   195
void GUrlSearchItem::layoutToEditMode(const bool editMode)
hgs
parents: 14
diff changeset
   196
{
hgs
parents: 14
diff changeset
   197
    m_urlSearchBtn->setVisible(editMode);
hgs
parents: 14
diff changeset
   198
    m_urlSearchEditor->changeEditorMode(editMode);
hgs
parents: 14
diff changeset
   199
    changeLayout(editMode);
hgs
parents: 14
diff changeset
   200
}
hgs
parents: 14
diff changeset
   201
#endif
hgs
parents: 14
diff changeset
   202
hgs
parents: 14
diff changeset
   203
void GUrlSearchItem::urlSearchActivatedByEnterKey()
hgs
parents: 14
diff changeset
   204
{
hgs
parents: 14
diff changeset
   205
    m_urlSearchEditor->removeFocus();
hgs
parents: 14
diff changeset
   206
    urlSearchActivated();
3
hgs
parents: 0
diff changeset
   207
}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
3
hgs
parents: 0
diff changeset
   209
void GUrlSearchItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
hgs
parents: 0
diff changeset
   210
{
hgs
parents: 0
diff changeset
   211
    Q_UNUSED(option);
hgs
parents: 0
diff changeset
   212
    Q_UNUSED(widget);
hgs
parents: 0
diff changeset
   213
hgs
parents: 0
diff changeset
   214
    painter->save();
hgs
parents: 0
diff changeset
   215
    painter->setRenderHint(QPainter::Antialiasing);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
3
hgs
parents: 0
diff changeset
   217
    if (m_padding > 0 || m_border > 0) {
hgs
parents: 0
diff changeset
   218
        QPainterPath border;
hgs
parents: 0
diff changeset
   219
        border.addRect(boundingRect());
hgs
parents: 0
diff changeset
   220
        border.addRoundedRect(
hgs
parents: 0
diff changeset
   221
                m_padding,
hgs
parents: 0
diff changeset
   222
                m_padding,
hgs
parents: 0
diff changeset
   223
                m_viewPortWidth,
hgs
parents: 0
diff changeset
   224
                m_viewPortHeight,
hgs
parents: 0
diff changeset
   225
                4,
hgs
parents: 0
diff changeset
   226
                4);
hgs
parents: 0
diff changeset
   227
hgs
parents: 0
diff changeset
   228
        if (m_padding > 0) {
hgs
parents: 0
diff changeset
   229
            painter->fillPath(border, m_borderColor);
hgs
parents: 0
diff changeset
   230
        }
hgs
parents: 0
diff changeset
   231
hgs
parents: 0
diff changeset
   232
        if (m_border > 0) {
hgs
parents: 0
diff changeset
   233
            QPen pen;
hgs
parents: 0
diff changeset
   234
            pen.setWidth(m_border);
hgs
parents: 0
diff changeset
   235
            pen.setBrush(m_borderColor);
hgs
parents: 0
diff changeset
   236
            painter->setPen(pen);
hgs
parents: 0
diff changeset
   237
            painter->drawPath(border);
hgs
parents: 0
diff changeset
   238
        }
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
3
hgs
parents: 0
diff changeset
   241
    painter->restore();
16
hgs
parents: 14
diff changeset
   242
#ifndef BROWSER_LAYOUT_TENONE
3
hgs
parents: 0
diff changeset
   243
    NativeChromeItem::paint(painter, option, widget);
16
hgs
parents: 14
diff changeset
   244
#endif
12
hgs
parents: 9
diff changeset
   245
hgs
parents: 9
diff changeset
   246
}
hgs
parents: 9
diff changeset
   247
hgs
parents: 9
diff changeset
   248
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   249
void GUrlSearchItem::changeToUrl(QPointF& pos)
hgs
parents: 9
diff changeset
   250
{
hgs
parents: 9
diff changeset
   251
    ViewController * viewController = m_chrome->viewController();
16
hgs
parents: 14
diff changeset
   252
    ControllableViewBase* curView = viewController->currentView();
12
hgs
parents: 9
diff changeset
   253
16
hgs
parents: 14
diff changeset
   254
    if( curView && curView->type() == "webView" ) {
12
hgs
parents: 9
diff changeset
   255
        emit changeEditMode(true);
16
hgs
parents: 14
diff changeset
   256
        layoutToEditMode(true);
12
hgs
parents: 9
diff changeset
   257
        m_urlSearchEditor->grabFocus();
hgs
parents: 9
diff changeset
   258
        tapped(pos);
hgs
parents: 9
diff changeset
   259
        m_urlSearchEditor->openVKB();
16
hgs
parents: 14
diff changeset
   260
    }
12
hgs
parents: 9
diff changeset
   261
}
hgs
parents: 9
diff changeset
   262
hgs
parents: 9
diff changeset
   263
void GUrlSearchItem::changeToTitle()
hgs
parents: 9
diff changeset
   264
{
hgs
parents: 9
diff changeset
   265
    emit changeEditMode(false);
16
hgs
parents: 14
diff changeset
   266
    layoutToEditMode(false);
12
hgs
parents: 9
diff changeset
   267
}
hgs
parents: 9
diff changeset
   268
hgs
parents: 9
diff changeset
   269
#endif
hgs
parents: 9
diff changeset
   270
hgs
parents: 9
diff changeset
   271
void GUrlSearchItem::onContentMouseEvent(QEvent::Type type )
hgs
parents: 9
diff changeset
   272
{
hgs
parents: 9
diff changeset
   273
hgs
parents: 9
diff changeset
   274
    //qDebug() << "UrlSearchItem::onContentMouseEvent" << type;
hgs
parents: 9
diff changeset
   275
    // We are dismissing the VKB on mouse release so that if the mouse press was on a link
hgs
parents: 9
diff changeset
   276
    // we will not close VKB that might cause a shift in geometry which can potentially prevent
hgs
parents: 9
diff changeset
   277
    // the link from being selected
hgs
parents: 9
diff changeset
   278
    if ((WebPageController::getSingleton()->editMode()) && (type == QEvent::GraphicsSceneMouseRelease)) {
hgs
parents: 9
diff changeset
   279
        // Edit canceled, so update LoadController state
hgs
parents: 9
diff changeset
   280
        changeLoadState(false);
hgs
parents: 9
diff changeset
   281
    
hgs
parents: 9
diff changeset
   282
        m_urlSearchEditor->closeVKB();
hgs
parents: 9
diff changeset
   283
hgs
parents: 9
diff changeset
   284
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   285
        if (! WebPageController::getSingleton()->isPageLoading())
hgs
parents: 9
diff changeset
   286
            changeToTitle();
hgs
parents: 9
diff changeset
   287
        // Set the text to the url of page
hgs
parents: 9
diff changeset
   288
        setUrlText(urlToBeDisplayed());
hgs
parents: 9
diff changeset
   289
#endif
hgs
parents: 9
diff changeset
   290
    }
hgs
parents: 9
diff changeset
   291
    
3
hgs
parents: 0
diff changeset
   292
}
hgs
parents: 0
diff changeset
   293
hgs
parents: 0
diff changeset
   294
void GUrlSearchItem::onChromeComplete()
hgs
parents: 0
diff changeset
   295
{
12
hgs
parents: 9
diff changeset
   296
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 9
diff changeset
   297
hgs
parents: 9
diff changeset
   298
    safe_connect(pageController, SIGNAL(pageUrlChanged(const QString)),
hgs
parents: 9
diff changeset
   299
            this, SLOT(setUrlText(const QString &)))
hgs
parents: 9
diff changeset
   300
hgs
parents: 9
diff changeset
   301
    safe_connect(pageController, SIGNAL(pageLoadStarted()),
hgs
parents: 9
diff changeset
   302
            this, SLOT(setStarted()));
hgs
parents: 9
diff changeset
   303
hgs
parents: 9
diff changeset
   304
    safe_connect(pageController, SIGNAL(pageLoadProgress(const int)),
hgs
parents: 9
diff changeset
   305
            this, SLOT(setProgress(int)));
hgs
parents: 9
diff changeset
   306
hgs
parents: 9
diff changeset
   307
    safe_connect(pageController, SIGNAL(pageLoadFinished(bool)),
hgs
parents: 9
diff changeset
   308
            this, SLOT(setFinished(bool)));
hgs
parents: 9
diff changeset
   309
hgs
parents: 9
diff changeset
   310
    safe_connect(pageController, SIGNAL(pageCreated(WRT::WrtBrowserContainer*)),
hgs
parents: 9
diff changeset
   311
            this, SLOT(setPageCreated()));
hgs
parents: 9
diff changeset
   312
hgs
parents: 9
diff changeset
   313
    safe_connect(pageController, SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)),
hgs
parents: 9
diff changeset
   314
            this, SLOT(setPageChanged()));
hgs
parents: 9
diff changeset
   315
hgs
parents: 9
diff changeset
   316
    safe_connect(pageController, SIGNAL(pageLoadFailed()),
hgs
parents: 9
diff changeset
   317
            this, SLOT(setPageFailed()));
hgs
parents: 9
diff changeset
   318
#ifdef BROWSER_LAYOUT_TENONE
16
hgs
parents: 14
diff changeset
   319
    safe_connect(pageController, SIGNAL(titleChanged(const QString&)), this, SLOT(onTitleChange(const QString&)));
hgs
parents: 14
diff changeset
   320
    
hgs
parents: 14
diff changeset
   321
    // Check for secure URL state change to change between the url and lock indicator icons in the url title indicator button
hgs
parents: 14
diff changeset
   322
    safe_connect(pageController, SIGNAL(showSecureIcon(bool)),
hgs
parents: 14
diff changeset
   323
            this, SLOT(showSecureIcon(bool)));
12
hgs
parents: 9
diff changeset
   324
#endif
16
hgs
parents: 14
diff changeset
   325
			
12
hgs
parents: 9
diff changeset
   326
    // Monitor view changes.
hgs
parents: 9
diff changeset
   327
hgs
parents: 9
diff changeset
   328
    ViewController * viewController = m_chrome->viewController();
16
hgs
parents: 14
diff changeset
   329
    
hgs
parents: 14
diff changeset
   330
    safe_connect(viewController, SIGNAL(currentViewChanged(ControllableViewBase *)),
hgs
parents: 14
diff changeset
   331
            this, SLOT(viewChanged(ControllableViewBase *)));
12
hgs
parents: 9
diff changeset
   332
hgs
parents: 9
diff changeset
   333
    GWebContentView* webView = static_cast<GWebContentView*> (m_chrome->getView("WebView"));
hgs
parents: 9
diff changeset
   334
    safe_connect(webView, SIGNAL(contentViewMouseEvent(QEvent::Type )), this, SLOT(onContentMouseEvent(QEvent::Type )));
hgs
parents: 9
diff changeset
   335
hgs
parents: 9
diff changeset
   336
3
hgs
parents: 0
diff changeset
   337
    setStarted();
16
hgs
parents: 14
diff changeset
   338
#ifndef Q_WS_MAEMO_5
3
hgs
parents: 0
diff changeset
   339
    WRT::WindowFlowView* windowView = static_cast<WRT::WindowFlowView *>(m_chrome->viewController()->view("WindowView"));
hgs
parents: 0
diff changeset
   340
    safe_connect(windowView, SIGNAL(newWindowTransitionComplete()), this, SLOT(onNewWindowTransitionComplete()));
16
hgs
parents: 14
diff changeset
   341
#endif
3
hgs
parents: 0
diff changeset
   342
    PageSnippet * suggestSnippet = qobject_cast<PageSnippet*>(m_chrome->getSnippet("SuggestsChromeId"));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
3
hgs
parents: 0
diff changeset
   344
    // instantiate items needed to display suggest page snippet
hgs
parents: 0
diff changeset
   345
    if (suggestSnippet) {
hgs
parents: 0
diff changeset
   346
        suggestSnippet->instantiate();
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
3
hgs
parents: 0
diff changeset
   350
void GUrlSearchItem::setStarted()
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
{
3
hgs
parents: 0
diff changeset
   352
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 0
diff changeset
   353
    ViewController * viewController = m_chrome->viewController();
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
12
hgs
parents: 9
diff changeset
   355
#ifdef BROWSER_LAYOUT_TENONE
16
hgs
parents: 14
diff changeset
   356
    showSecureIcon(false);
12
hgs
parents: 9
diff changeset
   357
    emit changeEditMode(false);
16
hgs
parents: 14
diff changeset
   358
    layoutToEditMode(true);
12
hgs
parents: 9
diff changeset
   359
#endif
hgs
parents: 9
diff changeset
   360
hgs
parents: 9
diff changeset
   361
    QString url = pageController->currentRequestedUrl();
hgs
parents: 9
diff changeset
   362
    if(!url.contains(KBOOKMARKURLFILESLASH)){
hgs
parents: 9
diff changeset
   363
       if(url.contains(KBOOKMARKURLFILE))
hgs
parents: 9
diff changeset
   364
          url.replace(QString(KBOOKMARKURLFILE), QString(KBOOKMARKURLFILESLASH));
hgs
parents: 9
diff changeset
   365
    }
hgs
parents: 9
diff changeset
   366
    setUrlText(url);
3
hgs
parents: 0
diff changeset
   367
    ControllableViewBase* curView = viewController->currentView();
hgs
parents: 0
diff changeset
   368
    if (curView && curView->type() == "webView") {
hgs
parents: 0
diff changeset
   369
        GWebContentView * gView = qobject_cast<GWebContentView*> (curView);
hgs
parents: 0
diff changeset
   370
        bool isSuperPage = gView ? gView->currentPageIsSuperPage() : false;
hgs
parents: 0
diff changeset
   371
        if(!isSuperPage)
12
hgs
parents: 9
diff changeset
   372
          m_chrome->layout()->slideView(100);
3
hgs
parents: 0
diff changeset
   373
    }
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    // Strictly speaking we should set progress to 0.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
    // But set it higher to give immediate visual feedback
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
    // that something is happening.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
    int progress = 0;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
    if (pageController->isPageLoading()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
        progress = 5;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
3
hgs
parents: 0
diff changeset
   384
    m_urlSearchEditor->setProgress(progress);
hgs
parents: 0
diff changeset
   385
    updateUrlSearchBtn();
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
3
hgs
parents: 0
diff changeset
   388
void GUrlSearchItem::setProgress(int percent)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
{
16
hgs
parents: 14
diff changeset
   390
    ViewController * viewController = m_chrome->viewController();
hgs
parents: 14
diff changeset
   391
    ControllableViewBase* curView = viewController->currentView();
hgs
parents: 14
diff changeset
   392
    if ( curView && curView->type() == "webView" && m_urlSearchEditor )
hgs
parents: 14
diff changeset
   393
      m_urlSearchEditor->setProgress(percent);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
// Wait a half-second before actually clearing the progress bar.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
//
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
// We have to be careful of the following two use cases:
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
//
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
// 1. Another page starts loading between the call to setFinished()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
//    and the scheduled call to clearProgress().
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
//
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
//    We don't want to clear the progress bar if another page is
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
//    loading.  WebPageController::isPageLoading() can tell us
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
//    if that is the case.
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
// 2. Another page finishes loading between the call to setFinished()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
//    and the scheduled call to clearProgress().  The sequence here is:
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
//
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
//      setFinished(ok) // for URL #1
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
//      setFinished(ok) // for URL #2
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
//      clearProgress() // for URL #1
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
//      clearProgress() // for URL #2
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
//
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
//    We don't want to clear the progress bar in the first call to
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
//    clearProgress() because we want the progress bar to retain its
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
//    appearance for the full timeout period.  We manage this by
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
//    tracking the number of pending calls to clearProgress() and
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
//    only clearing the progress bar when that number becomes 0.
3
hgs
parents: 0
diff changeset
   420
void GUrlSearchItem::setFinished(bool ok)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
{
3
hgs
parents: 0
diff changeset
   422
    WebPageController * pageController = WebPageController::getSingleton();
12
hgs
parents: 9
diff changeset
   423
    ViewController * viewController = m_chrome->viewController();
16
hgs
parents: 14
diff changeset
   424
    ControllableViewBase* curView = viewController->currentView();
12
hgs
parents: 9
diff changeset
   425
    //qDebug() << "GUrlSearchItem::setFinished" << pageController->loadState();
hgs
parents: 9
diff changeset
   426
    
hgs
parents: 9
diff changeset
   427
    if (pageController->loadState() != WRT::LoadController::GotoModeEditing) {
hgs
parents: 9
diff changeset
   428
        m_urlSearchEditor->removeFocus();
hgs
parents: 9
diff changeset
   429
        
hgs
parents: 9
diff changeset
   430
        if ( ok && curView && curView->type() == "webView" ){
hgs
parents: 9
diff changeset
   431
            setUrlText(formattedUrl());
hgs
parents: 9
diff changeset
   432
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   433
            m_urlSearchEditor->setTitle(currentTitle());
hgs
parents: 9
diff changeset
   434
#endif
hgs
parents: 9
diff changeset
   435
        }
hgs
parents: 9
diff changeset
   436
        if (curView && curView->type() == "webView" && pageController->contentsYPos() > 0)
hgs
parents: 9
diff changeset
   437
          m_chrome->layout()->slideView(-100);
hgs
parents: 9
diff changeset
   438
    }
hgs
parents: 9
diff changeset
   439
    
3
hgs
parents: 0
diff changeset
   440
    // If the load was finished normally and not due to user stopping it,
hgs
parents: 0
diff changeset
   441
    // simulate progress completion
12
hgs
parents: 9
diff changeset
   442
    if ( !pageController->loadCanceled() && curView && curView->type() == "webView" )
3
hgs
parents: 0
diff changeset
   443
        m_urlSearchEditor->setProgress(100);
hgs
parents: 0
diff changeset
   444
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
    ++m_pendingClearCalls;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    QTimer::singleShot(500, this, SLOT(clearProgress()));
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
12
hgs
parents: 9
diff changeset
   450
void GUrlSearchItem::setPageFailed()
hgs
parents: 9
diff changeset
   451
{
hgs
parents: 9
diff changeset
   452
    WebPageController * pageController = WebPageController::getSingleton();
16
hgs
parents: 14
diff changeset
   453
    LoadController * loadController = pageController->currentPage()->loadController();
12
hgs
parents: 9
diff changeset
   454
    if( loadController->loadCanceled() && !loadController->pointOfNoReturn() )
hgs
parents: 9
diff changeset
   455
    {     
16
hgs
parents: 14
diff changeset
   456
        setUrlText(loadController->urlText());
12
hgs
parents: 9
diff changeset
   457
    }
hgs
parents: 9
diff changeset
   458
    else
hgs
parents: 9
diff changeset
   459
    {
16
hgs
parents: 14
diff changeset
   460
        setUrlText(formattedUrl());
hgs
parents: 14
diff changeset
   461
    }
hgs
parents: 14
diff changeset
   462
    #ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   463
     m_urlSearchEditor->setTitle(currentTitle());
hgs
parents: 14
diff changeset
   464
    #endif
12
hgs
parents: 9
diff changeset
   465
}
16
hgs
parents: 14
diff changeset
   466
3
hgs
parents: 0
diff changeset
   467
void GUrlSearchItem::setPageCreated()
hgs
parents: 0
diff changeset
   468
{
hgs
parents: 0
diff changeset
   469
    // remove slideview(100) since the new transition for the code-driven window
hgs
parents: 0
diff changeset
   470
    //m_chrome->layout()->slideView(100);
16
hgs
parents: 14
diff changeset
   471
    #ifdef Q_WS_MAEMO_5
hgs
parents: 14
diff changeset
   472
     setProgress(0); // no progress bar in new window shall be left from previous windows
hgs
parents: 14
diff changeset
   473
    #endif
3
hgs
parents: 0
diff changeset
   474
}
hgs
parents: 0
diff changeset
   475
hgs
parents: 0
diff changeset
   476
void GUrlSearchItem::setPageChanged()
hgs
parents: 0
diff changeset
   477
{
12
hgs
parents: 9
diff changeset
   478
    setUrlText(formattedUrl());
3
hgs
parents: 0
diff changeset
   479
    updateUrlSearchBtn();
12
hgs
parents: 9
diff changeset
   480
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 9
diff changeset
   481
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   482
    
hgs
parents: 9
diff changeset
   483
    ViewController * viewController = m_chrome->viewController();
hgs
parents: 9
diff changeset
   484
    ControllableViewBase* curView = viewController->currentView();
3
hgs
parents: 0
diff changeset
   485
12
hgs
parents: 9
diff changeset
   486
    QString title;
hgs
parents: 9
diff changeset
   487
    if (curView && curView->type() == KWindowViewName  ) {
hgs
parents: 9
diff changeset
   488
        title = getWindowsViewTitle();
hgs
parents: 9
diff changeset
   489
    }
hgs
parents: 9
diff changeset
   490
    else {
16
hgs
parents: 14
diff changeset
   491
        title = currentTitle();
12
hgs
parents: 9
diff changeset
   492
    }
hgs
parents: 9
diff changeset
   493
hgs
parents: 9
diff changeset
   494
    m_urlSearchEditor->setTitle(title);
hgs
parents: 9
diff changeset
   495
#endif
hgs
parents: 9
diff changeset
   496
hgs
parents: 9
diff changeset
   497
3
hgs
parents: 0
diff changeset
   498
    int progress = pageController->loadProgressValue();
hgs
parents: 0
diff changeset
   499
    if (progress == 100)
hgs
parents: 0
diff changeset
   500
        m_urlSearchEditor->removeFocus();
hgs
parents: 0
diff changeset
   501
}
hgs
parents: 0
diff changeset
   502
hgs
parents: 0
diff changeset
   503
void GUrlSearchItem::clearProgress()
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
    --m_pendingClearCalls;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
    if (m_pendingClearCalls > 0) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
        return;
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
    WebPageController * pageController = WebPageController::getSingleton();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    if (pageController->isPageLoading()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
        return;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    }
12
hgs
parents: 9
diff changeset
   515
3
hgs
parents: 0
diff changeset
   516
    m_urlSearchEditor->setProgress(0);
hgs
parents: 0
diff changeset
   517
    updateUrlSearchBtn();
12
hgs
parents: 9
diff changeset
   518
    
hgs
parents: 9
diff changeset
   519
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   520
    if ( !pageController->editMode() ) {
hgs
parents: 9
diff changeset
   521
        changeToTitle();
hgs
parents: 9
diff changeset
   522
    }
hgs
parents: 9
diff changeset
   523
#endif
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
16
hgs
parents: 14
diff changeset
   526
hgs
parents: 14
diff changeset
   527
void GUrlSearchItem::viewChanged(ControllableViewBase *newView)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
{
3
hgs
parents: 0
diff changeset
   529
    ViewController * viewController = m_chrome->viewController();
16
hgs
parents: 14
diff changeset
   530
    WebPageController * pageController = WebPageController::getSingleton(); 
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
3
hgs
parents: 0
diff changeset
   532
    ControllableViewBase* curView = viewController->currentView();
hgs
parents: 0
diff changeset
   533
    GWebContentView * gView = qobject_cast<GWebContentView*> (curView);
hgs
parents: 0
diff changeset
   534
    bool isSuperPage = gView ? gView->currentPageIsSuperPage() : false;
hgs
parents: 0
diff changeset
   535
16
hgs
parents: 14
diff changeset
   536
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   537
    QColor bgColor;
hgs
parents: 14
diff changeset
   538
    QColor textColor;
hgs
parents: 14
diff changeset
   539
    QColor titleColor;
hgs
parents: 14
diff changeset
   540
#endif
hgs
parents: 14
diff changeset
   541
    
3
hgs
parents: 0
diff changeset
   542
    // view changes to web content view
hgs
parents: 0
diff changeset
   543
    if (curView && curView->type() == "webView" && !isSuperPage) {
12
hgs
parents: 9
diff changeset
   544
        
hgs
parents: 9
diff changeset
   545
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   546
16
hgs
parents: 14
diff changeset
   547
        bgColor = Qt::transparent;
hgs
parents: 14
diff changeset
   548
        textColor = Qt::black;
hgs
parents: 14
diff changeset
   549
        titleColor = Qt::white;
hgs
parents: 14
diff changeset
   550
hgs
parents: 14
diff changeset
   551
        // when going to a web page view, set the correct icon for the url title indicator button state
hgs
parents: 14
diff changeset
   552
        if (pageController->secureState() == 0){
hgs
parents: 14
diff changeset
   553
            showSecureIcon(false);
hgs
parents: 14
diff changeset
   554
        } else {
hgs
parents: 14
diff changeset
   555
            showSecureIcon(true);
hgs
parents: 14
diff changeset
   556
        }
hgs
parents: 14
diff changeset
   557
12
hgs
parents: 9
diff changeset
   558
        if (pageController->isPageLoading()) {
16
hgs
parents: 14
diff changeset
   559
12
hgs
parents: 9
diff changeset
   560
            m_urlSearchEditor->changeEditorMode(true);
hgs
parents: 9
diff changeset
   561
            m_urlSearchBtn->show();
hgs
parents: 9
diff changeset
   562
#endif
hgs
parents: 9
diff changeset
   563
            int progress = pageController->loadProgressValue();
hgs
parents: 9
diff changeset
   564
            if (progress >= 100)
hgs
parents: 9
diff changeset
   565
                progress = 0;
hgs
parents: 9
diff changeset
   566
            m_urlSearchEditor->setProgress(progress);
hgs
parents: 9
diff changeset
   567
            updateUrlSearchBtn();
3
hgs
parents: 0
diff changeset
   568
12
hgs
parents: 9
diff changeset
   569
            // place focus in urlsearch bar when returning from adding a new window in windows view
hgs
parents: 9
diff changeset
   570
            if (pageController->loadText() == "") {
hgs
parents: 9
diff changeset
   571
                if (m_backFromNewWinTrans ) {
hgs
parents: 9
diff changeset
   572
                    m_backFromNewWinTrans = false;
hgs
parents: 9
diff changeset
   573
                    setUrlText(pageController->currentRequestedUrl());
hgs
parents: 9
diff changeset
   574
                }
hgs
parents: 9
diff changeset
   575
                else {
hgs
parents: 9
diff changeset
   576
                    m_urlSearchEditor->grabFocus();
hgs
parents: 9
diff changeset
   577
                }
3
hgs
parents: 0
diff changeset
   578
            }
12
hgs
parents: 9
diff changeset
   579
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   580
        }
hgs
parents: 9
diff changeset
   581
        else {
hgs
parents: 9
diff changeset
   582
            m_urlSearchEditor->setTitle(currentTitle());
3
hgs
parents: 0
diff changeset
   583
        }
12
hgs
parents: 9
diff changeset
   584
#endif
3
hgs
parents: 0
diff changeset
   585
        if (!isSuperPage  && (pageController->contentsYPos() <= 0 || pageController->isPageLoading())){
12
hgs
parents: 9
diff changeset
   586
            m_chrome->layout()->slideView(100);
3
hgs
parents: 0
diff changeset
   587
        } else {
12
hgs
parents: 9
diff changeset
   588
            m_chrome->layout()->slideView(-100);
3
hgs
parents: 0
diff changeset
   589
        }
hgs
parents: 0
diff changeset
   590
        m_backFromNewWinTrans = false;
hgs
parents: 0
diff changeset
   591
    } else {
12
hgs
parents: 9
diff changeset
   592
16
hgs
parents: 14
diff changeset
   593
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   594
     bgColor = Qt::transparent;
hgs
parents: 14
diff changeset
   595
     textColor = Qt::black;
hgs
parents: 14
diff changeset
   596
     titleColor = Qt::white;
hgs
parents: 14
diff changeset
   597
hgs
parents: 14
diff changeset
   598
     // when going to a view other than a web page, set the non-secure icon for the url title indicator button
hgs
parents: 14
diff changeset
   599
     hideIndicatorButton();
hgs
parents: 14
diff changeset
   600
#endif
hgs
parents: 14
diff changeset
   601
     
12
hgs
parents: 9
diff changeset
   602
     pageController->urlTextChanged(m_urlSearchEditor->text());
hgs
parents: 9
diff changeset
   603
     // Remove progress bar
hgs
parents: 9
diff changeset
   604
     // incorrect values are not seen before we can update when we come back
hgs
parents: 9
diff changeset
   605
     m_urlSearchEditor->setProgress(0);
hgs
parents: 9
diff changeset
   606
hgs
parents: 9
diff changeset
   607
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   608
     QString key = curView->objectName();
hgs
parents: 9
diff changeset
   609
     if (key == KWindowViewName) {
hgs
parents: 9
diff changeset
   610
         key = getWindowsViewTitle();
hgs
parents: 9
diff changeset
   611
     }
hgs
parents: 9
diff changeset
   612
     else if (key == KSettingsViewName) {
hgs
parents: 9
diff changeset
   613
         key = qtTrId("txt_browser_settings_settings");
hgs
parents: 9
diff changeset
   614
     }
hgs
parents: 9
diff changeset
   615
     else if (key == KBookmarkHistoryViewName) {
hgs
parents: 9
diff changeset
   616
         key = qtTrId("txt_browser_history_history");
hgs
parents: 9
diff changeset
   617
     }
hgs
parents: 9
diff changeset
   618
     else if (key == KBookmarkTreeViewName) {
hgs
parents: 9
diff changeset
   619
         key = qtTrId("txt_browser_bookmarks_bookmarks");
hgs
parents: 9
diff changeset
   620
     }
hgs
parents: 9
diff changeset
   621
     changeToTitle();
hgs
parents: 9
diff changeset
   622
     m_urlSearchEditor->setTitle(key);
hgs
parents: 9
diff changeset
   623
#else
hgs
parents: 9
diff changeset
   624
     m_chrome->layout()->slideView(-100);
hgs
parents: 9
diff changeset
   625
#endif 
3
hgs
parents: 0
diff changeset
   626
    }
16
hgs
parents: 14
diff changeset
   627
    
hgs
parents: 14
diff changeset
   628
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   629
    m_urlSearchEditor->setBackgroundColor(bgColor);
hgs
parents: 14
diff changeset
   630
    m_urlSearchEditor->setTextColor(textColor);
hgs
parents: 14
diff changeset
   631
    // reset the layout for secure icon
hgs
parents: 14
diff changeset
   632
    changeLayout(m_urlSearchBtn->isVisible());
hgs
parents: 14
diff changeset
   633
#endif
3
hgs
parents: 0
diff changeset
   634
}
hgs
parents: 0
diff changeset
   635
12
hgs
parents: 9
diff changeset
   636
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   637
void GUrlSearchItem::onTitleChange(const QString& text)
hgs
parents: 9
diff changeset
   638
{
16
hgs
parents: 14
diff changeset
   639
    ViewController * viewController = m_chrome->viewController();
hgs
parents: 14
diff changeset
   640
    ControllableViewBase* curView = viewController->currentView();
hgs
parents: 14
diff changeset
   641
    if ( curView && curView->type() == "webView" ){
hgs
parents: 14
diff changeset
   642
         m_urlSearchEditor->setTitle(text);
hgs
parents: 14
diff changeset
   643
    }
12
hgs
parents: 9
diff changeset
   644
}
hgs
parents: 9
diff changeset
   645
hgs
parents: 9
diff changeset
   646
QString GUrlSearchItem::getWindowsViewTitle() {
hgs
parents: 9
diff changeset
   647
    QString title =  currentTitle();
hgs
parents: 9
diff changeset
   648
    if (title.isEmpty()) {
hgs
parents: 9
diff changeset
   649
        title = qtTrId("txt_browser_windows_windows");
hgs
parents: 9
diff changeset
   650
        title += ": ";
hgs
parents: 9
diff changeset
   651
        title += qtTrId("txt_browser_windows_new_window");
hgs
parents: 9
diff changeset
   652
    }
hgs
parents: 9
diff changeset
   653
    else {
hgs
parents: 9
diff changeset
   654
        title.prepend(": ");
hgs
parents: 9
diff changeset
   655
        title.prepend(qtTrId("txt_browser_windows_windows"));
hgs
parents: 9
diff changeset
   656
            
hgs
parents: 9
diff changeset
   657
    }
hgs
parents: 9
diff changeset
   658
    return title;
hgs
parents: 9
diff changeset
   659
}
hgs
parents: 9
diff changeset
   660
16
hgs
parents: 14
diff changeset
   661
void GUrlSearchItem::showSecureIcon(bool show)
3
hgs
parents: 0
diff changeset
   662
{
16
hgs
parents: 14
diff changeset
   663
    m_urlTitleIndBtn->setVisible(!show);
hgs
parents: 14
diff changeset
   664
    m_urlTitleIndSecureBtn->setVisible(show);
3
hgs
parents: 0
diff changeset
   665
}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
16
hgs
parents: 14
diff changeset
   667
void GUrlSearchItem::hideIndicatorButton()
hgs
parents: 14
diff changeset
   668
{
hgs
parents: 14
diff changeset
   669
    m_urlTitleIndBtn->hide();
hgs
parents: 14
diff changeset
   670
    m_urlTitleIndSecureBtn->hide();
hgs
parents: 14
diff changeset
   671
}
hgs
parents: 14
diff changeset
   672
hgs
parents: 14
diff changeset
   673
#endif
hgs
parents: 14
diff changeset
   674
3
hgs
parents: 0
diff changeset
   675
void GUrlSearchItem::urlSearchActivated()
hgs
parents: 0
diff changeset
   676
{
hgs
parents: 0
diff changeset
   677
    WebPageController * pageController = WebPageController::getSingleton();
16
hgs
parents: 14
diff changeset
   678
    switch (pageController->loadState()) {
hgs
parents: 14
diff changeset
   679
        case WRT::LoadController::GotoModeLoading:
hgs
parents: 14
diff changeset
   680
            pageController->currentStop();
hgs
parents: 14
diff changeset
   681
            ++m_pendingClearCalls;
hgs
parents: 14
diff changeset
   682
            QTimer::singleShot(500, this, SLOT(clearProgress()));
hgs
parents: 14
diff changeset
   683
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   684
            layoutToEditMode(false);
hgs
parents: 14
diff changeset
   685
#endif
hgs
parents: 14
diff changeset
   686
            break;
hgs
parents: 14
diff changeset
   687
        case WRT::LoadController::GotoModeEditing:
hgs
parents: 14
diff changeset
   688
            loadToMainWindow();
hgs
parents: 14
diff changeset
   689
            break;
hgs
parents: 14
diff changeset
   690
        case WRT::LoadController::GotoModeReloadable:
hgs
parents: 14
diff changeset
   691
            if (pageController->currentDocUrl() == m_urlSearchEditor->text())
hgs
parents: 14
diff changeset
   692
                pageController->currentReload();
hgs
parents: 14
diff changeset
   693
            else
hgs
parents: 14
diff changeset
   694
                loadToMainWindow();
hgs
parents: 14
diff changeset
   695
            break;
hgs
parents: 14
diff changeset
   696
        default:
hgs
parents: 14
diff changeset
   697
            qDebug() << "GUrlSearchItem::urlSearchActivated() Incorrect state";
hgs
parents: 14
diff changeset
   698
            break;
hgs
parents: 14
diff changeset
   699
    }
hgs
parents: 14
diff changeset
   700
    updateUrlSearchBtn();
3
hgs
parents: 0
diff changeset
   701
}
hgs
parents: 0
diff changeset
   702
16
hgs
parents: 14
diff changeset
   703
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   704
void GUrlSearchItem::urlTitleIndBtnActivated()
hgs
parents: 14
diff changeset
   705
{
hgs
parents: 14
diff changeset
   706
    // When the url title indicator button is pressed, focus into the url text area
hgs
parents: 14
diff changeset
   707
    QPointF pos(0, 0);
hgs
parents: 14
diff changeset
   708
    changeToUrl(pos);
hgs
parents: 14
diff changeset
   709
}
hgs
parents: 14
diff changeset
   710
#endif
hgs
parents: 14
diff changeset
   711
3
hgs
parents: 0
diff changeset
   712
void GUrlSearchItem::updateUrlSearchBtn()
hgs
parents: 0
diff changeset
   713
{
16
hgs
parents: 14
diff changeset
   714
    
3
hgs
parents: 0
diff changeset
   715
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 0
diff changeset
   716
    switch (pageController->loadState()) {
hgs
parents: 0
diff changeset
   717
        case WRT::LoadController::GotoModeLoading:
hgs
parents: 0
diff changeset
   718
            m_urlSearchBtn->addIcon(STOP_BUTTON_ICON);
hgs
parents: 0
diff changeset
   719
            break;
12
hgs
parents: 9
diff changeset
   720
        case WRT::LoadController::GotoModeEditinLoading:
3
hgs
parents: 0
diff changeset
   721
        case WRT::LoadController::GotoModeEditing:
hgs
parents: 0
diff changeset
   722
            m_urlSearchBtn->addIcon(GO_BUTTON_ICON);
hgs
parents: 0
diff changeset
   723
            break;
hgs
parents: 0
diff changeset
   724
        case WRT::LoadController::GotoModeReloadable:
12
hgs
parents: 9
diff changeset
   725
            m_urlSearchBtn->addIcon(GO_BUTTON_ICON);
3
hgs
parents: 0
diff changeset
   726
            break;
hgs
parents: 0
diff changeset
   727
        default:
12
hgs
parents: 9
diff changeset
   728
            qDebug() << "GUrlSearchItem::updateUrlSearchBtn Incorrect state";
3
hgs
parents: 0
diff changeset
   729
            break;
hgs
parents: 0
diff changeset
   730
    }
hgs
parents: 0
diff changeset
   731
    m_urlSearchBtn->update();
hgs
parents: 0
diff changeset
   732
    
hgs
parents: 0
diff changeset
   733
    // notify suggest object of changes in load state
hgs
parents: 0
diff changeset
   734
    PageSnippet * suggestSnippet = qobject_cast<PageSnippet*>(m_chrome->getSnippet("SuggestsChromeId"));
hgs
parents: 0
diff changeset
   735
    if (suggestSnippet) {
hgs
parents: 0
diff changeset
   736
        QString cmd = "searchSuggests.updateLoadState();";
hgs
parents: 0
diff changeset
   737
        suggestSnippet->evaluateJavaScript(cmd);
hgs
parents: 0
diff changeset
   738
    }
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
16
hgs
parents: 14
diff changeset
   741
void GUrlSearchItem::createEditor()
hgs
parents: 14
diff changeset
   742
{
hgs
parents: 14
diff changeset
   743
    QColor textColor;
hgs
parents: 14
diff changeset
   744
    QColor backgroundColor;
hgs
parents: 14
diff changeset
   745
    QColor progressColor;
hgs
parents: 14
diff changeset
   746
    
hgs
parents: 14
diff changeset
   747
    QWebElement we = m_snippet->element();
hgs
parents: 14
diff changeset
   748
    NativeChromeItem::CSSToQColor(
hgs
parents: 14
diff changeset
   749
            we.styleProperty("border-bottom-color", QWebElement::ComputedStyle),
hgs
parents: 14
diff changeset
   750
            progressColor);
hgs
parents: 14
diff changeset
   751
    
hgs
parents: 14
diff changeset
   752
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   753
    QFont titleFont;
hgs
parents: 14
diff changeset
   754
    QColor titleColor;
hgs
parents: 14
diff changeset
   755
    textColor = QColor(Qt::black);
hgs
parents: 14
diff changeset
   756
    titleColor = QColor(Qt::white);
hgs
parents: 14
diff changeset
   757
    m_borderColor = QColor(Qt::transparent);
hgs
parents: 14
diff changeset
   758
    backgroundColor = QColor(Qt::transparent);
hgs
parents: 14
diff changeset
   759
    
hgs
parents: 14
diff changeset
   760
    titleFont = QFont(QApplication::font());
hgs
parents: 14
diff changeset
   761
    titleFont.setPointSize(9);
hgs
parents: 14
diff changeset
   762
    titleFont.setWeight(QFont::Bold);
hgs
parents: 14
diff changeset
   763
#endif
hgs
parents: 14
diff changeset
   764
#ifndef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   765
    NativeChromeItem::CSSToQColor(
hgs
parents: 14
diff changeset
   766
            we.styleProperty("color", QWebElement::ComputedStyle),
hgs
parents: 14
diff changeset
   767
            textColor);
hgs
parents: 14
diff changeset
   768
hgs
parents: 14
diff changeset
   769
    NativeChromeItem::CSSToQColor(
hgs
parents: 14
diff changeset
   770
            we.styleProperty("background-color", QWebElement::ComputedStyle),
hgs
parents: 14
diff changeset
   771
            backgroundColor);
hgs
parents: 14
diff changeset
   772
hgs
parents: 14
diff changeset
   773
    NativeChromeItem::CSSToQColor(
hgs
parents: 14
diff changeset
   774
            we.styleProperty("border-top-color", QWebElement::ComputedStyle),
hgs
parents: 14
diff changeset
   775
            m_borderColor);
hgs
parents: 14
diff changeset
   776
#endif
hgs
parents: 14
diff changeset
   777
    
hgs
parents: 14
diff changeset
   778
    // Create the url search editor
hgs
parents: 14
diff changeset
   779
    m_urlSearchEditor = new GProgressEditor(m_snippet, m_chrome, m_viewPort);
hgs
parents: 14
diff changeset
   780
    m_urlSearchEditor->setObjectName("UrlEditor");
hgs
parents: 14
diff changeset
   781
    m_urlSearchEditor->setTextColor(textColor);
hgs
parents: 14
diff changeset
   782
 #ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   783
    m_urlSearchEditor->setTitleFont(titleFont);
hgs
parents: 14
diff changeset
   784
    m_urlSearchEditor->setTitleColor(titleColor);
hgs
parents: 14
diff changeset
   785
 #endif
hgs
parents: 14
diff changeset
   786
    m_urlSearchEditor->setBackgroundColor(backgroundColor);
hgs
parents: 14
diff changeset
   787
    m_urlSearchEditor->setProgressColor(progressColor);
hgs
parents: 14
diff changeset
   788
    m_urlSearchEditor->setBorderColor(m_borderColor);
hgs
parents: 14
diff changeset
   789
    m_urlSearchEditor->setPadding(0.1); // draw the Rounded Rect
hgs
parents: 14
diff changeset
   790
    m_urlSearchEditor->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
hgs
parents: 14
diff changeset
   791
    m_urlSearchEditor->setSpecificButton(SPECIFIC_BUTTON_STRING, SPECIFIC_BUTTON_ICON);
hgs
parents: 14
diff changeset
   792
    safe_connect(m_urlSearchEditor, SIGNAL(contentsChange(int, int, int)), 
hgs
parents: 14
diff changeset
   793
        this, SLOT(updateLoadStateAndSuggest(int, int, int)));
hgs
parents: 14
diff changeset
   794
    safe_connect(m_urlSearchEditor, SIGNAL(activated()),this, SLOT(urlSearchActivatedByEnterKey()));
hgs
parents: 14
diff changeset
   795
    safe_connect(m_urlSearchEditor, SIGNAL(focusChanged(bool)),this, SLOT(focusChanged(bool)));
hgs
parents: 14
diff changeset
   796
#ifndef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   797
    safe_connect(m_urlSearchEditor, SIGNAL(tapped(QPointF&)),this, SLOT(tapped(QPointF&)));
hgs
parents: 14
diff changeset
   798
#endif    
hgs
parents: 14
diff changeset
   799
    safe_connect(m_urlSearchEditor, SIGNAL(contextEvent(bool)), this, SIGNAL(contextEvent(bool)));
hgs
parents: 14
diff changeset
   800
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   801
    safe_connect(m_urlSearchEditor, SIGNAL(titleMouseEvent(QPointF&)),this, SLOT(changeToUrl(QPointF&)));
hgs
parents: 14
diff changeset
   802
#endif
hgs
parents: 14
diff changeset
   803
}
hgs
parents: 14
diff changeset
   804
hgs
parents: 14
diff changeset
   805
void GUrlSearchItem::createIcons()
hgs
parents: 14
diff changeset
   806
{
hgs
parents: 14
diff changeset
   807
    // Create the url search button
hgs
parents: 14
diff changeset
   808
    m_urlSearchBtn = new ActionButton(m_snippet, "UrlSearchButton", m_viewPort);
hgs
parents: 14
diff changeset
   809
    QAction* urlSearchBtnAction = new QAction(this);
hgs
parents: 14
diff changeset
   810
    m_urlSearchBtn->setAction(urlSearchBtnAction); // FIXME: should use diff QActions
hgs
parents: 14
diff changeset
   811
    m_urlSearchBtn->setActiveOnPress(false);
hgs
parents: 14
diff changeset
   812
    safe_connect(urlSearchBtnAction, SIGNAL(triggered()), this, SLOT(urlSearchActivated()));
hgs
parents: 14
diff changeset
   813
    
hgs
parents: 14
diff changeset
   814
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   815
    // Create the url title indicator button (NOTE: QAction created but not hooked up)
hgs
parents: 14
diff changeset
   816
    m_urlTitleIndBtn = new ActionButton(m_snippet, "UrlSearchIndButton", m_viewPort);
hgs
parents: 14
diff changeset
   817
    QAction* urlTitleIndBtnAction = new QAction(this);
hgs
parents: 14
diff changeset
   818
    m_urlTitleIndBtn->setAction(urlTitleIndBtnAction);
hgs
parents: 14
diff changeset
   819
    m_urlTitleIndBtn->addIcon(URL_TITLE_IND_BUTTON_ICON);
hgs
parents: 14
diff changeset
   820
    m_urlTitleIndBtn->setActiveOnPress(false);
hgs
parents: 14
diff changeset
   821
    safe_connect(urlTitleIndBtnAction, SIGNAL(triggered()), this, SLOT(urlTitleIndBtnActivated()));
hgs
parents: 14
diff changeset
   822
    
hgs
parents: 14
diff changeset
   823
    m_urlTitleIndSecureBtn = new ActionButton(m_snippet, "UrlSearchSecureButton", m_viewPort);
hgs
parents: 14
diff changeset
   824
    QAction* urlTitleIndSecureBtnAction = new QAction(this);
hgs
parents: 14
diff changeset
   825
    m_urlTitleIndSecureBtn->setAction(urlTitleIndSecureBtnAction);
hgs
parents: 14
diff changeset
   826
    m_urlTitleIndSecureBtn->addIcon(URL_TITLE_IND_SECURE_BUTTON_ICON);
hgs
parents: 14
diff changeset
   827
    m_urlTitleIndSecureBtn->setActiveOnPress(false);
hgs
parents: 14
diff changeset
   828
    safe_connect(urlTitleIndSecureBtnAction, SIGNAL(triggered()), this, SLOT(urlTitleIndBtnActivated()));
hgs
parents: 14
diff changeset
   829
hgs
parents: 14
diff changeset
   830
#endif
hgs
parents: 14
diff changeset
   831
    
hgs
parents: 14
diff changeset
   832
    QIcon btnIcon(GO_BUTTON_ICON);
hgs
parents: 14
diff changeset
   833
    QSize actualSize = btnIcon.availableSizes()[0];
hgs
parents: 14
diff changeset
   834
    m_buttonIconWidth = actualSize.width();
hgs
parents: 14
diff changeset
   835
    m_buttonIconHeight = actualSize.height();
hgs
parents: 14
diff changeset
   836
hgs
parents: 14
diff changeset
   837
#ifndef BROWSER_LAYOUT_TENONE
hgs
parents: 14
diff changeset
   838
    m_urlSearchEditor->setRightTextMargin(m_buttonIconWidth + BETWEEN_ENTRY_AND_BUTTON_SPACE);
hgs
parents: 14
diff changeset
   839
hgs
parents: 14
diff changeset
   840
#endif
hgs
parents: 14
diff changeset
   841
hgs
parents: 14
diff changeset
   842
}
hgs
parents: 14
diff changeset
   843
3
hgs
parents: 0
diff changeset
   844
void GUrlSearchItem::loadToMainWindow()
hgs
parents: 0
diff changeset
   845
{
hgs
parents: 0
diff changeset
   846
    QString url = m_urlSearchEditor->text();
12
hgs
parents: 9
diff changeset
   847
    if(!url.contains(KBOOKMARKURLFILESLASH)){
hgs
parents: 9
diff changeset
   848
       if(url.contains(KBOOKMARKURLFILE))
hgs
parents: 9
diff changeset
   849
          url.replace(QString(KBOOKMARKURLFILE), QString(KBOOKMARKURLFILESLASH));
hgs
parents: 9
diff changeset
   850
    }
3
hgs
parents: 0
diff changeset
   851
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 0
diff changeset
   852
    QString gotourl = pageController->guessUrlFromString(url);
12
hgs
parents: 9
diff changeset
   853
    setUrlText(gotourl);
3
hgs
parents: 0
diff changeset
   854
    pageController->currentLoad(gotourl);
hgs
parents: 0
diff changeset
   855
    pageController->urlTextChanged(gotourl);
12
hgs
parents: 9
diff changeset
   856
#ifdef BROWSER_LAYOUT_TENONE
hgs
parents: 9
diff changeset
   857
    m_urlSearchEditor->closeVKB();
hgs
parents: 9
diff changeset
   858
#endif
3
hgs
parents: 0
diff changeset
   859
}
hgs
parents: 0
diff changeset
   860
12
hgs
parents: 9
diff changeset
   861
void GUrlSearchItem::updateLoadStateAndSuggest(int /*position*/, int charsRemoved, int charsAdded)
3
hgs
parents: 0
diff changeset
   862
{
hgs
parents: 0
diff changeset
   863
    WebPageController * pageController = WebPageController::getSingleton();
16
hgs
parents: 14
diff changeset
   864
    if (url().contains('\n'))
hgs
parents: 14
diff changeset
   865
    {
hgs
parents: 14
diff changeset
   866
        urlSearchActivatedByEnterKey();
hgs
parents: 14
diff changeset
   867
        return;
hgs
parents: 14
diff changeset
   868
    }
hgs
parents: 14
diff changeset
   869
    
12
hgs
parents: 9
diff changeset
   870
    // will get contentsChanged() signal on programmatic changes and sometimes 
hgs
parents: 9
diff changeset
   871
    // position changes but we are only interested in user input
hgs
parents: 9
diff changeset
   872
    if ((charsRemoved || charsAdded) && pageController->editMode()) {
hgs
parents: 9
diff changeset
   873
        PageSnippet * suggestSnippet = qobject_cast<PageSnippet*>(m_chrome->getSnippet("SuggestsChromeId"));
hgs
parents: 9
diff changeset
   874
        if (suggestSnippet) {
hgs
parents: 9
diff changeset
   875
            QString cmd = "searchSuggests.updateUserInput();";
hgs
parents: 9
diff changeset
   876
            suggestSnippet->evaluateJavaScript(cmd);
hgs
parents: 9
diff changeset
   877
        }
hgs
parents: 9
diff changeset
   878
    }
16
hgs
parents: 14
diff changeset
   879
12
hgs
parents: 9
diff changeset
   880
}
hgs
parents: 9
diff changeset
   881
hgs
parents: 9
diff changeset
   882
hgs
parents: 9
diff changeset
   883
void GUrlSearchItem::changeLoadState(bool editing) {
hgs
parents: 9
diff changeset
   884
hgs
parents: 9
diff changeset
   885
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 9
diff changeset
   886
    if (pageController->editMode() != editing)  {
hgs
parents: 9
diff changeset
   887
        pageController->setEditMode(editing);
3
hgs
parents: 0
diff changeset
   888
        updateUrlSearchBtn();
hgs
parents: 0
diff changeset
   889
    }
hgs
parents: 0
diff changeset
   890
}
hgs
parents: 0
diff changeset
   891
void GUrlSearchItem::tapped(QPointF& pos)
hgs
parents: 0
diff changeset
   892
{
12
hgs
parents: 9
diff changeset
   893
    changeLoadState(true);
3
hgs
parents: 0
diff changeset
   894
    bool hitText = m_urlSearchEditor->tappedOnText(pos.x());
hgs
parents: 0
diff changeset
   895
    if (!m_justFocusIn && !hitText)
hgs
parents: 0
diff changeset
   896
        m_urlSearchEditor->unselect();
hgs
parents: 0
diff changeset
   897
hgs
parents: 0
diff changeset
   898
    if (m_justFocusIn) {
hgs
parents: 0
diff changeset
   899
        m_justFocusIn = false;
12
hgs
parents: 9
diff changeset
   900
3
hgs
parents: 0
diff changeset
   901
        if (hitText && !m_urlSearchEditor->hasSelection())
hgs
parents: 0
diff changeset
   902
            m_urlSearchEditor->selectAll();
hgs
parents: 0
diff changeset
   903
    }
hgs
parents: 0
diff changeset
   904
}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
3
hgs
parents: 0
diff changeset
   906
void GUrlSearchItem::focusChanged(bool focusIn)
hgs
parents: 0
diff changeset
   907
{
12
hgs
parents: 9
diff changeset
   908
    // Suggestion snippet needs to know about this event.
hgs
parents: 9
diff changeset
   909
    PageSnippet * suggestSnippet = qobject_cast<PageSnippet*>(m_chrome->getSnippet("SuggestsChromeId"));
hgs
parents: 9
diff changeset
   910
    if (suggestSnippet) {
hgs
parents: 9
diff changeset
   911
        QString cmd("searchSuggests.urlSearchFocusChanged(");
hgs
parents: 9
diff changeset
   912
        cmd += focusIn ? "true);" : "false);";
hgs
parents: 9
diff changeset
   913
        suggestSnippet->evaluateJavaScript(cmd);
hgs
parents: 9
diff changeset
   914
    }
hgs
parents: 9
diff changeset
   915
hgs
parents: 9
diff changeset
   916
    if (focusIn) {
3
hgs
parents: 0
diff changeset
   917
        m_justFocusIn = true;
12
hgs
parents: 9
diff changeset
   918
    }
3
hgs
parents: 0
diff changeset
   919
    else {
hgs
parents: 0
diff changeset
   920
        m_justFocusIn = false;
hgs
parents: 0
diff changeset
   921
    }
hgs
parents: 0
diff changeset
   922
}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
3
hgs
parents: 0
diff changeset
   924
void GUrlSearchItem::resize()
hgs
parents: 0
diff changeset
   925
{
hgs
parents: 0
diff changeset
   926
    QWebElement we = m_snippet->element();
hgs
parents: 0
diff changeset
   927
    QRectF g = we.geometry();
hgs
parents: 0
diff changeset
   928
    qreal newWidth  = g.width();
hgs
parents: 0
diff changeset
   929
    qreal newHeight = g.height();
hgs
parents: 0
diff changeset
   930
    QGraphicsWidget::resize(newWidth, newHeight);
hgs
parents: 0
diff changeset
   931
}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   932
3
hgs
parents: 0
diff changeset
   933
void GUrlSearchItem::onNewWindowTransitionComplete()
hgs
parents: 0
diff changeset
   934
{
hgs
parents: 0
diff changeset
   935
    m_backFromNewWinTrans = true;
hgs
parents: 0
diff changeset
   936
}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   937
3
hgs
parents: 0
diff changeset
   938
QString GUrlSearchItem::formattedUrl() const
hgs
parents: 0
diff changeset
   939
{
hgs
parents: 0
diff changeset
   940
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 0
diff changeset
   941
    QString url = pageController->loadText();
12
hgs
parents: 9
diff changeset
   942
    
3
hgs
parents: 0
diff changeset
   943
    // for first load of the windows restored from last session
hgs
parents: 0
diff changeset
   944
    if (url.isEmpty()&& pageController->currentDocUrl().isEmpty()) {
hgs
parents: 0
diff changeset
   945
        QWebHistoryItem item = pageController->currentPage()->history()->currentItem();
hgs
parents: 0
diff changeset
   946
        url = item.url().toString();
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
    }
12
hgs
parents: 9
diff changeset
   948
3
hgs
parents: 0
diff changeset
   949
    return url.replace(" ","+");
hgs
parents: 0
diff changeset
   950
}
hgs
parents: 0
diff changeset
   951
16
hgs
parents: 14
diff changeset
   952
12
hgs
parents: 9
diff changeset
   953
void GUrlSearchItem::setUrlText(const QString & str) 
hgs
parents: 9
diff changeset
   954
{
hgs
parents: 9
diff changeset
   955
	ViewController * viewController = m_chrome->viewController();
hgs
parents: 9
diff changeset
   956
	ControllableViewBase* curView = viewController->currentView();
16
hgs
parents: 14
diff changeset
   957
	if ( curView && curView->type() == "webView" ) {
hgs
parents: 14
diff changeset
   958
        QUrl url(str);
hgs
parents: 14
diff changeset
   959
	    m_urlSearchEditor->setText(WRT::UiUtil::encodeQueryItems(url, true).toString());
hgs
parents: 14
diff changeset
   960
	}
12
hgs
parents: 9
diff changeset
   961
}
hgs
parents: 9
diff changeset
   962
hgs
parents: 9
diff changeset
   963
QString GUrlSearchItem::urlToBeDisplayed() 
hgs
parents: 9
diff changeset
   964
{
hgs
parents: 9
diff changeset
   965
hgs
parents: 9
diff changeset
   966
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 9
diff changeset
   967
    QString url = pageController->currentDocUrl();
hgs
parents: 9
diff changeset
   968
    if (url.isEmpty() ) {
hgs
parents: 9
diff changeset
   969
        url = pageController->currentRequestedUrl();
hgs
parents: 9
diff changeset
   970
    }
hgs
parents: 9
diff changeset
   971
    //qDebug() << "GUrlSearchItem::urlToBeDisplayed" << url;
hgs
parents: 9
diff changeset
   972
    return url;
hgs
parents: 9
diff changeset
   973
}
hgs
parents: 9
diff changeset
   974
hgs
parents: 9
diff changeset
   975
QString GUrlSearchItem::currentTitle() 
hgs
parents: 9
diff changeset
   976
{
hgs
parents: 9
diff changeset
   977
hgs
parents: 9
diff changeset
   978
    WebPageController * pageController = WebPageController::getSingleton();
hgs
parents: 9
diff changeset
   979
    QString title  = pageController->currentDocTitle();
hgs
parents: 9
diff changeset
   980
    if (title.isEmpty() ){ 
hgs
parents: 9
diff changeset
   981
        title = pageController->currentPartialUrl();
16
hgs
parents: 14
diff changeset
   982
        if (title.isEmpty() ) {
hgs
parents: 14
diff changeset
   983
             // New Window, so set title as such
hgs
parents: 14
diff changeset
   984
            title = qtTrId("txt_browser_windows_new_window");
hgs
parents: 14
diff changeset
   985
        }
12
hgs
parents: 9
diff changeset
   986
    }
hgs
parents: 9
diff changeset
   987
    return title;
hgs
parents: 9
diff changeset
   988
}
hgs
parents: 9
diff changeset
   989
16
hgs
parents: 14
diff changeset
   990
12
hgs
parents: 9
diff changeset
   991
// GUrlSearchSnippet class
hgs
parents: 9
diff changeset
   992
hgs
parents: 9
diff changeset
   993
3
hgs
parents: 0
diff changeset
   994
GUrlSearchSnippet::GUrlSearchSnippet(const QString & elementId, ChromeWidget * chrome,
hgs
parents: 0
diff changeset
   995
                         QGraphicsWidget * widget, const QWebElement & element)
hgs
parents: 0
diff changeset
   996
  : ChromeSnippet(elementId, chrome, widget, element)
hgs
parents: 0
diff changeset
   997
{
hgs
parents: 0
diff changeset
   998
}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   999
3
hgs
parents: 0
diff changeset
  1000
GUrlSearchSnippet * GUrlSearchSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element)
hgs
parents: 0
diff changeset
  1001
{
hgs
parents: 0
diff changeset
  1002
    GUrlSearchSnippet* that = new GUrlSearchSnippet(elementId, chrome, 0, element);
16
hgs
parents: 14
diff changeset
  1003
    GUrlSearchItem* urlSearchItem = new GUrlSearchItem(that, chrome);
hgs
parents: 14
diff changeset
  1004
    safe_connect(urlSearchItem, SIGNAL(contextEvent(bool)), that, SLOT(sendContextMenuEvent(bool)));
hgs
parents: 14
diff changeset
  1005
    that->setChromeWidget(urlSearchItem);
3
hgs
parents: 0
diff changeset
  1006
    return that;
hgs
parents: 0
diff changeset
  1007
}
hgs
parents: 0
diff changeset
  1008
16
hgs
parents: 14
diff changeset
  1009
void GUrlSearchSnippet::sendContextMenuEvent(bool isContentSelected)
3
hgs
parents: 0
diff changeset
  1010
{
16
hgs
parents: 14
diff changeset
  1011
    emit contextEvent(isContentSelected, elementId());
3
hgs
parents: 0
diff changeset
  1012
}
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1013
16
hgs
parents: 14
diff changeset
  1014
GUrlSearchItem* GUrlSearchSnippet::urlSearchItem()
3
hgs
parents: 0
diff changeset
  1015
{
16
hgs
parents: 14
diff changeset
  1016
    return qobject_cast<GUrlSearchItem *>(widget());
hgs
parents: 14
diff changeset
  1017
}
hgs
parents: 14
diff changeset
  1018
hgs
parents: 14
diff changeset
  1019
GUrlSearchItem const * GUrlSearchSnippet::constUrlSearchItem() const
hgs
parents: 14
diff changeset
  1020
{
hgs
parents: 14
diff changeset
  1021
    return qobject_cast<GUrlSearchItem const *>(constWidget());
3
hgs
parents: 0
diff changeset
  1022
}
hgs
parents: 0
diff changeset
  1023
hgs
parents: 0
diff changeset
  1024
QString GUrlSearchSnippet::url() const
hgs
parents: 0
diff changeset
  1025
{
hgs
parents: 0
diff changeset
  1026
    return constUrlSearchItem()->url();
hgs
parents: 0
diff changeset
  1027
}
hgs
parents: 0
diff changeset
  1028
hgs
parents: 0
diff changeset
  1029
void GUrlSearchSnippet::setUrl(const QString &url)
hgs
parents: 0
diff changeset
  1030
{
hgs
parents: 0
diff changeset
  1031
    urlSearchItem()->setUrl(url);
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1033
16
hgs
parents: 14
diff changeset
  1034
void GUrlSearchSnippet::cut()
hgs
parents: 14
diff changeset
  1035
{
hgs
parents: 14
diff changeset
  1036
    urlSearchItem()->cut();
hgs
parents: 14
diff changeset
  1037
}
hgs
parents: 14
diff changeset
  1038
hgs
parents: 14
diff changeset
  1039
void GUrlSearchSnippet::copy()
hgs
parents: 14
diff changeset
  1040
{
hgs
parents: 14
diff changeset
  1041
    urlSearchItem()->copy();
hgs
parents: 14
diff changeset
  1042
}
hgs
parents: 14
diff changeset
  1043
hgs
parents: 14
diff changeset
  1044
void GUrlSearchSnippet::paste()
hgs
parents: 14
diff changeset
  1045
{
hgs
parents: 14
diff changeset
  1046
    urlSearchItem()->paste();
hgs
parents: 14
diff changeset
  1047
}
hgs
parents: 14
diff changeset
  1048
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1049
} // namespace GVA