|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 #include "mostvisitedsnippetmaemo.h" |
|
22 #include "MostVisitedView.h" |
|
23 #include "Utilities.h" |
|
24 #include "ExternalEventCharm.h" |
|
25 |
|
26 namespace GVA { |
|
27 |
|
28 MostVisitedSnippet::MostVisitedSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element) : |
|
29 ChromeSnippet(elementId, chrome, widget, element), |
|
30 m_externalEventCharm(0) |
|
31 { |
|
32 m_chrome = chrome; |
|
33 } |
|
34 |
|
35 MostVisitedSnippet::~MostVisitedSnippet() |
|
36 { |
|
37 disconnect(m_chrome , SIGNAL(aspectChanged(int)), this, SLOT(displayModeChanged(int))); |
|
38 delete m_externalEventCharm; |
|
39 } |
|
40 |
|
41 MostVisitedSnippet * MostVisitedSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) |
|
42 { |
|
43 MostVisitedSnippet* that = new MostVisitedSnippet(elementId, chrome, 0, element); |
|
44 |
|
45 that->setChromeWidget( new MostVisitedView(qtTrId("txt_browser_most_visited_title_most_visited"), chrome->layout()) ); |
|
46 that->widget()->hide(); //TODO: Shouldn't be needed? |
|
47 return that; |
|
48 } |
|
49 |
|
50 void MostVisitedSnippet::toggleVisibility(bool animate) |
|
51 { |
|
52 MostVisitedView *mostVisitedPagesWidget = dynamic_cast<MostVisitedView*>(widget()); |
|
53 if (!mostVisitedPagesWidget) |
|
54 return; |
|
55 |
|
56 if (!isVisible()) { |
|
57 mostVisitedPagesWidget->setGeometry(10, 10, 784, 335); |
|
58 mostVisitedPagesWidget->update("landscape"); // it does not matter for Maemo (landscape mode only for now) |
|
59 mostVisitedPagesWidget->show(); |
|
60 ChromeSnippet::toggleVisibility(animate); |
|
61 |
|
62 } else { |
|
63 mostVisitedPagesWidget->close(); |
|
64 } |
|
65 } |
|
66 |
|
67 void MostVisitedSnippet::setChromeWidget(QGraphicsWidget * widget) |
|
68 { |
|
69 //safe_connect(m_chrome , SIGNAL(aspectChanged(int)), this, SLOT(displayModeChanged(int))); |
|
70 ChromeSnippet::setChromeWidget(widget); |
|
71 MostVisitedView *mostVisitedPagesWidget = dynamic_cast<MostVisitedView*>(widget); |
|
72 safe_connect(mostVisitedPagesWidget, SIGNAL(closeComplete()), this, SLOT(onWidgetCloseComplete())); |
|
73 // m_externalEventCharm = new ExternalEventCharm(widget); |
|
74 // safe_connect(m_externalEventCharm, SIGNAL(externalMouseEvent(QEvent *, const QString &, const QString &)), |
|
75 // this, SIGNAL(externalMouseEvent(QEvent *, const QString &, const QString &))); |
|
76 } |
|
77 |
|
78 void MostVisitedSnippet::displayModeChanged(int newMode) |
|
79 { |
|
80 /* TO DO: reenable this code. |
|
81 |
|
82 if (isVisible()) { |
|
83 MostVisitedView *mostVisitedView = dynamic_cast<MostVisitedView*>(widget()); |
|
84 |
|
85 if (!mostVisitedPagesWidget) |
|
86 return; |
|
87 |
|
88 updateMVGeometry(); |
|
89 |
|
90 QString displayMode = (newMode == landscape) ? "Landscape" : "Portrait"; |
|
91 mostVisitedPagesWidget->displayModeChanged(displayMode); |
|
92 } |
|
93 */ |
|
94 } |
|
95 |
|
96 void MostVisitedSnippet::hide(bool animate) |
|
97 { |
|
98 MostVisitedView *mostVisitedPagesWidget = dynamic_cast<MostVisitedView*>(widget()); |
|
99 |
|
100 if (!mostVisitedPagesWidget) |
|
101 return; |
|
102 |
|
103 ChromeSnippet::hide(animate); |
|
104 // mostVisitedPagesWidget->closeAnimationCompleted(); |
|
105 } |
|
106 |
|
107 void MostVisitedSnippet::close() |
|
108 { |
|
109 MostVisitedView *mostVisitedPagesWidget = dynamic_cast<MostVisitedView*>(widget()); |
|
110 |
|
111 if (mostVisitedPagesWidget) { |
|
112 mostVisitedPagesWidget->close(); |
|
113 } |
|
114 } |
|
115 |
|
116 void MostVisitedSnippet::onWidgetCloseComplete() { // slot |
|
117 if (isVisible()) |
|
118 ChromeSnippet::toggleVisibility(); |
|
119 emit mostVisitedSnippetCloseComplete(); |
|
120 } |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 } |