22 #include "Utilities.h" |
22 #include "Utilities.h" |
23 #include <QtCore/QUrl> |
23 #include <QtCore/QUrl> |
24 #include "ViewStack.h" |
24 #include "ViewStack.h" |
25 #include "ViewController.h" |
25 #include "ViewController.h" |
26 #include "webpagecontroller.h" |
26 #include "webpagecontroller.h" |
27 #include "HistoryFlowView.h" |
|
28 #include "WindowFlowView.h" |
27 #include "WindowFlowView.h" |
29 #include "ChromeSnippet.h" |
28 #include "ChromeSnippet.h" |
30 |
29 |
31 namespace GVA { |
30 namespace GVA { |
32 |
31 |
33 static const QString KBookmarkHistoryViewName = "BookmarkHistoryView"; |
32 static const QString KBookmarkHistoryViewName = "BookmarkHistoryView"; |
34 static const QString KBookmarkTreeViewName = "BookmarkTreeView"; |
33 static const QString KBookmarkTreeViewName = "BookmarkTreeView"; |
35 static const QString KWebViewName = "WebView"; |
34 static const QString KWebViewName = "WebView"; |
36 static const QString KWindowViewName = "WindowView"; |
35 static const QString KWindowViewName = "WindowView"; |
37 static const QString KHistoryViewName = "HistoryView"; |
|
38 static const QString KSettingsViewName = "SettingsView"; |
36 static const QString KSettingsViewName = "SettingsView"; |
39 |
37 |
40 |
38 |
41 ViewStack* ViewStack::getSingleton() |
39 ViewStack* ViewStack::getSingleton() |
42 { |
40 { |
114 visibleSnippet->hide(); |
112 visibleSnippet->hide(); |
115 } |
113 } |
116 |
114 |
117 void ViewStack::toWindowView() |
115 void ViewStack::toWindowView() |
118 { |
116 { |
|
117 WRT::WindowFlowView* windowView = static_cast<WRT::WindowFlowView *>(m_viewController->view(KWindowViewName)); |
|
118 // Set the window size before windows view is activated |
|
119 windowView->setSize( m_chrome->viewSize()); |
119 emit(activateWindowView()); |
120 emit(activateWindowView()); |
120 |
121 |
121 ChromeSnippet* tbSnippet = m_chrome->getSnippet("WindowViewToolbarId"); |
122 ChromeSnippet* tbSnippet = m_chrome->getSnippet("WindowViewToolbarId"); |
122 if (tbSnippet) |
123 if (tbSnippet) |
123 tbSnippet->show(); |
124 tbSnippet->show(); |
124 |
125 |
125 WRT::WindowFlowView* windowView = static_cast<WRT::WindowFlowView *>(m_viewController->view(KWindowViewName)); |
|
126 |
126 |
127 safe_connect(windowView, SIGNAL(ok(WrtBrowserContainer*)), this, SLOT(goBackFromWindowView())); |
127 safe_connect(windowView, SIGNAL(ok(WrtBrowserContainer*)), this, SLOT(goBackFromWindowView())); |
128 safe_connect(windowView, SIGNAL(addPageComplete()), this, SLOT(goBackFromWindowView())); |
128 safe_connect(windowView, SIGNAL(addPageComplete()), this, SLOT(goBackFromWindowView())); |
129 safe_connect(windowView, SIGNAL(centerIndexChanged(int)), this, SIGNAL(pageChanged(int))); |
129 safe_connect(windowView, SIGNAL(centerIndexChanged(int)), this, SIGNAL(pageChanged(int))); |
130 } |
130 } |
165 void ViewStack::creatingPage(WRT::WrtBrowserContainer* page) { |
165 void ViewStack::creatingPage(WRT::WrtBrowserContainer* page) { |
166 Q_UNUSED(page); |
166 Q_UNUSED(page); |
167 |
167 |
168 //qDebug() << "VIEW STACK:: Received creating Page" << page; |
168 //qDebug() << "VIEW STACK:: Received creating Page" << page; |
169 |
169 |
|
170 #ifndef Q_WS_MAEMO_5 |
170 if (m_viewController->currentView()->type() == "webView" ) { |
171 if (m_viewController->currentView()->type() == "webView" ) { |
171 //qDebug() << "ViewStack::page: " << page << "Created In " << m_viewController->currentView()->type() ; |
172 //qDebug() << "ViewStack::page: " << page << "Created In " << m_viewController->currentView()->type() ; |
172 |
173 |
173 WRT::WindowFlowView* windowView = static_cast<WRT::WindowFlowView *>(m_viewController->view(KWindowViewName)); |
174 WRT::WindowFlowView* windowView = static_cast<WRT::WindowFlowView *>(m_viewController->view(KWindowViewName)); |
174 windowView->setMode(WRT::WindowView::WindowViewModeTransition); |
175 windowView->setMode(WRT::WindowView::WindowViewModeTransition); |
175 windowView->onPageCreated(page); |
176 windowView->onPageCreated(page); |
176 ViewStack::getSingleton()->switchView(KWindowViewName, KWebViewName); |
177 ViewStack::getSingleton()->switchView(KWindowViewName, KWebViewName); |
177 } |
178 } |
178 |
179 #endif |
179 } |
180 } |
180 |
181 |
181 void ViewStack::switchView(const QString &to, const QString &from) { |
182 void ViewStack::switchView(const QString &to, const QString &from) { |
182 |
183 |
183 if (to == from) { |
184 if (to == from) { |
184 return; |
185 return; |
185 } |
186 } |
186 if (!m_viewController) { |
187 if (!m_viewController) { |
187 return; |
188 return; |
188 } |
189 } |
189 |
190 // set required data before switching to windows view |
|
191 if (to == KWindowViewName) { |
|
192 toWindowView(); |
|
193 } |
190 if (from == KWindowViewName) { |
194 if (from == KWindowViewName) { |
191 fromWindowView(to); |
195 fromWindowView(to); |
192 } |
196 } |
193 else if (from == KWebViewName) { |
197 else if (from == KWebViewName) { |
194 fromWebView(to); |
198 fromWebView(to); |
201 } |
205 } |
202 else if (from == KSettingsViewName) { |
206 else if (from == KSettingsViewName) { |
203 fromSettingsView(to); |
207 fromSettingsView(to); |
204 } |
208 } |
205 |
209 |
206 if (to == KWindowViewName) { |
210 if (to == KWebViewName) { |
207 toWindowView(); |
|
208 } |
|
209 else if (to == KWebViewName) { |
|
210 toWebView(); |
211 toWebView(); |
211 } |
212 } |
212 else if (to == KBookmarkHistoryViewName) { |
213 else if (to == KBookmarkHistoryViewName) { |
213 toBookmarkHistoryView(); |
214 toBookmarkHistoryView(); |
214 } |
215 } |
218 else if (to == KSettingsViewName) { |
219 else if (to == KSettingsViewName) { |
219 toSettingsView(); |
220 toSettingsView(); |
220 } |
221 } |
221 } |
222 } |
222 |
223 |
223 |
224 void ViewStack::goBackFromWindowView() { |
224 void ViewStack::loadHistoryItem(int item) { |
225 switchView(KWebViewName, KWindowViewName); |
|
226 } |
|
227 |
|
228 void ViewStack::goBackFromRecentUrlView() { |
|
229 switchView(KWebViewName, KBookmarkHistoryViewName); |
|
230 } |
|
231 |
|
232 void ViewStack::goBackFromBookmarkView() { |
|
233 switchView(KWebViewName, KBookmarkTreeViewName); |
|
234 } |
|
235 |
|
236 void ViewStack::goBackFromSettingsView() { |
|
237 switchView(KWebViewName, KSettingsViewName); |
|
238 } |
|
239 |
|
240 void ViewStack::showContentView(int progress) { |
|
241 Q_UNUSED(progress); |
225 |
242 |
226 if (!m_viewController) { |
243 if (!m_viewController) { |
227 return; |
244 return; |
228 } |
245 } |
229 WRT::HistoryFlowView* historyView = static_cast<WRT::HistoryFlowView*>(m_viewController->view(KHistoryViewName)); |
|
230 //var myIndex = window.viewManager.historyView.currentHistIndex; |
|
231 int myIndex = historyView->currentIndex(); |
|
232 |
|
233 if (myIndex != item ) { |
|
234 //window.chrome.alert("loadFromHistory"); |
|
235 WebPageController::getSingleton()->currentSetFromHistory(item); |
|
236 safe_connect(m_viewController,SIGNAL(loadProgess(const int)), this, SLOT(showContentView(const int))); |
|
237 } |
|
238 } |
|
239 |
|
240 void ViewStack::goBackFromWindowView() { |
|
241 switchView(KWebViewName, KWindowViewName); |
|
242 } |
|
243 |
|
244 void ViewStack::goBackFromRecentUrlView() { |
|
245 switchView(KWebViewName, KBookmarkHistoryViewName); |
|
246 } |
|
247 |
|
248 void ViewStack::goBackFromBookmarkView() { |
|
249 switchView(KWebViewName, KBookmarkTreeViewName); |
|
250 } |
|
251 |
|
252 void ViewStack::goBackFromSettingsView() { |
|
253 switchView(KWebViewName, KSettingsViewName); |
|
254 } |
|
255 |
|
256 void ViewStack::showContentView(int progress) { |
|
257 Q_UNUSED(progress); |
|
258 |
|
259 if (!m_viewController) { |
|
260 return; |
|
261 } |
|
262 |
246 |
263 if ( m_viewController->currentView()->type() == KWebViewName ) { |
247 if ( m_viewController->currentView()->type() == KWebViewName ) { |
264 disconnect(m_viewController,SIGNAL(loadProgess(const int)), this, SLOT(showContentView(const int))); |
248 disconnect(m_viewController,SIGNAL(loadProgess(const int)), this, SLOT(showContentView(const int))); |
265 } |
249 } |
266 } |
250 } |