browsercore/appfw/Api/Managers/LoadController.cpp
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
child 5 0f2326c2a325
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/browsercore/appfw/Api/Managers/LoadController.cpp	Tue May 04 12:39:35 2010 +0300
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include "LoadController.h"
+#include <QDebug>
+
+namespace WRT {
+
+LoadController::LoadController ( ) :
+    m_gotoMode(GotoModeEditing), 
+    m_isPageLoading(false), 
+    m_canceled(false),
+    m_progress(0)
+{
+
+}
+
+LoadController::~LoadController()
+{
+
+}
+
+void LoadController::setMode(GotoBrowserMode mode)
+{
+    m_gotoMode = mode;
+}
+
+LoadController::GotoBrowserMode LoadController::mode()
+{
+    return m_gotoMode;
+}
+
+void LoadController::loadStarted()
+{
+    m_progress = 0;
+    m_canceled = 0;
+    m_isPageLoading = true;
+
+    m_gotoMode = GotoModeLoading;
+
+    //qDebug() << __PRETTY_FUNCTION__;
+    emit pageLoadStarted();
+}
+
+void LoadController::loadFinished(bool ok)
+{
+    //qDebug() << __PRETTY_FUNCTION__  << ok << m_gotoMode ;
+    m_isPageLoading = false;
+
+    m_progress = 100;
+
+    m_gotoMode = GotoModeReloadable;
+
+// TODO: Change to editing mode if load failed
+/*
+    // if page succeed, set the text and goto reloading mode, else load mode
+    if(ok)
+    {
+        m_gotoMode = GotoModeReloadable;
+
+    }
+    else
+    {
+        m_gotoMode = GotoModeEditing;
+    }
+*/
+    emit pageLoadFinished(ok);
+    //qDebug() << __PRETTY_FUNCTION__  << m_gotoMode ;
+}
+
+void LoadController::loadProgress(int progress)
+{
+    m_progress = progress;
+
+    //qDebug() << __PRETTY_FUNCTION__  << progress ;
+    emit pageLoadProgress(progress);
+}
+
+void LoadController::urlChanged(QUrl url) 
+{
+//    qDebug() << __PRETTY_FUNCTION__  << url;
+    // Save the url 
+    m_textBoxValue = url.toString();
+    emit pageUrlChanged(m_textBoxValue);
+}
+	
+void LoadController::setUrlText(QString str)
+{
+//    qDebug() << __PRETTY_FUNCTION__  << str;
+    m_textBoxValue = str; 
+}
+
+} // namespace WRT