author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 23 Jun 2010 17:59:43 +0300 | |
changeset 5 | 0f2326c2a325 |
child 6 | 1c3b8676e58c |
permissions | -rw-r--r-- |
5
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU Lesser General Public License as published by |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 2.1 of the License. |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* GNU Lesser General Public License for more details. |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU Lesser General Public License |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* along with this program. If not, |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
* |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
* Description: |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
* This class extends ToolbarSnippet class to hold the |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
* windows view toolbar buttons |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
* |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
*/ |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#include "RecentUrlToolbarSnippet.h" |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include "ViewStack.h" |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
#include "GWebContentView.h" |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
#include "BookmarksManager.h" |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include <QDebug> |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
namespace GVA { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
RecentUrlToolbarSnippet::RecentUrlToolbarSnippet(const QString& elementId, ChromeWidget * chrome, |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget) |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
: DualButtonToolbarSnippet(elementId, chrome, ownerArea, element, widget), |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
m_action1(0) |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
{ |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
RecentUrlToolbarSnippet::~RecentUrlToolbarSnippet() |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
{ |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
if(m_action1) |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
delete m_action1; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
void RecentUrlToolbarSnippet::addChild(ChromeSnippet * child) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
WebChromeContainerSnippet * s = dynamic_cast<WebChromeContainerSnippet* >(child); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
if (!s) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
ToolbarActions_t* t = new ToolbarActions_t(); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
if (child->elementId() == "RecentBackButton" ) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
t->actionId = RECENTURL_VIEW_ACTION_BACK; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
t->actionName = RECENTURL_TOOLBAR_BACK; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
t->disabledImg = ""; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
else if (child->elementId() == "RecentClearallButton" ) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
t->actionId = RECENTURL_VIEW_ACTION_CLEARALL; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
t->actionName = RECENTURL_TOOLBAR_CLEARALL; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall.png"; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
t->disabledImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_disabled.png"; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_pressed.png"; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
t->id = child->elementId(); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
m_actionInfo.append(t); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
WebChromeContainerSnippet::addChild(child); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
void RecentUrlToolbarSnippet::setAction(ChromeSnippet * s) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
ToolbarSnippet::setAction(s); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
ActionButtonSnippet * button = static_cast<ActionButtonSnippet*> (s); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
int index = getIndex(s); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
if (index != -1 ) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
ToolbarActions_t * t = m_actionInfo.at(index); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
QAction * action = button->getDefaultAction(); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
if (t->actionId == RECENTURL_VIEW_ACTION_BACK ) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
if( !action ) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
action = new QAction(0); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
button->setDefaultAction(action); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
m_action1 = action; |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
84 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
connect(action, SIGNAL(triggered()), this, SLOT(handleBackButton())); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
87 |
else if (t->actionId == RECENTURL_VIEW_ACTION_CLEARALL) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
88 |
if( !action ) { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
89 |
// Action is created/handled/owned by BookmarksManager |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
QAction * a = WRT::BookmarksManager::getSingleton()->getActionClearHistory(); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
button->setDefaultAction(a); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
93 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
void RecentUrlToolbarSnippet::handleBackButton() { |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
98 |
GWebContentView* webView = static_cast<GWebContentView*> (chrome()->getView("WebView")); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
99 |
if(webView) |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
100 |
webView->showNormalPage(); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
101 |
ViewStack::getSingleton()->switchView( TOOLBAR_WEB_VIEW, TOOLBAR_RECENTURL_VIEW ); |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
102 |
} |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
} // end of namespace GVA |
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
105 |
|
0f2326c2a325
Revision: 201024
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |