--- a/ginebra2/mostvisitedpageview.cpp Fri May 14 15:40:36 2010 +0300
+++ b/ginebra2/mostvisitedpageview.cpp Tue Jun 29 00:46:29 2010 -0400
@@ -1,21 +1,24 @@
/*
* Copyright (c) 2010 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".
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, version 2.1 of the License.
*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
*
-* Contributors:
+* You should have received a copy of the GNU Lesser General Public License
+* along with this program. If not,
+* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
*
-* Description:
+* Description:
*
*/
-
#include <QtGui>
#include "mostvisitedpagestore.h"
@@ -23,22 +26,24 @@
#include "mostvisitedpageview.h"
#include "webpagecontroller.h"
#include "BookmarksManager.h"
+#include "webpagedata.h"
const int KLinearSnippetHeight = 120;
namespace GVA {
-MostVisitedPagesWidget::MostVisitedPagesWidget(ChromeSnippet* snippet,QGraphicsWidget* parent)
- : m_snippet(snippet)
- , QGraphicsWidget(parent)
- , m_parent(parent)
- , m_flowInterface(0)
- , m_hideOnClose(true)
+MostVisitedPagesWidget::MostVisitedPagesWidget(ChromeSnippet* snippet, ChromeWidget* chrome)
+ : ChromeItem(snippet, chrome->layout())
+ , m_parent(chrome->layout())
+ , m_chrome(chrome)
+ , m_flowInterface(0)
+ , m_hideOnClose(true)
{
setFlags(QGraphicsItem::ItemDoesntPropagateOpacityToChildren);
setOpacity(0.5);
m_mostVisitedPageStore = new MostVisitedPageStore();
WebPageController* pageController = WebPageController::getSingleton();
- bool ret = connect(pageController, SIGNAL(loadFinished(const bool)), this, SLOT(onLoadFinished(const bool)));
+ connect(pageController, SIGNAL(loadFinished(const bool)), this, SLOT(onLoadFinished(const bool)));
+ connect(WRT::BookmarksManager::getSingleton(),SIGNAL(historyCleared()),this,SLOT(clearMVStore()));
}
MostVisitedPagesWidget::~MostVisitedPagesWidget()
@@ -48,7 +53,8 @@
if (m_mostVisitedPageStore)
delete m_mostVisitedPageStore;
WebPageController* pageController = WebPageController::getSingleton();
- disconnect(pageController, SIGNAL(loadFinished()), this, SLOT(onLoadFinished()));
+ disconnect(pageController, SIGNAL(loadFinished(const bool)), this, SLOT(onLoadFinished(const bool)));
+ disconnect(WRT::BookmarksManager::getSingleton(),SIGNAL(historyCleared()),this,SLOT(clearMVStore()));
}
@@ -60,20 +66,20 @@
m_flowInterface = new GVA::LinearFlowSnippet(this);
m_flowInterface->setZValue(m_parent->zValue() + 1);
m_flowInterface->resize(QSize(m_parent->size().width(), KLinearSnippetHeight));
- connect(m_flowInterface, SIGNAL(mouseEvent(QEvent::Type)),this->m_snippet,SIGNAL(snippetMouseEvent(QEvent::Type)));
-
+ connect(m_flowInterface, SIGNAL(mouseEvent(QEvent::Type)),this,SIGNAL(mouseEvent(QEvent::Type)));
+
//Initialize the page selection index
m_selectIndex = -1;
-
+
QString displayMode;
if (m_parent->size().width() > m_parent->size().height()) {
displayMode = "Landscape";
-
+
} else {
displayMode = "Portrait";
}
- m_flowInterface->init(displayMode,"Most Visited Pages");
+ m_flowInterface->init(displayMode,qtTrId("txt_browser_most_visited_title"));
MostVisitedPageList mvPageList = m_mostVisitedPageStore->pageList();
@@ -90,7 +96,7 @@
delete pageThumbnail;
}
}
-
+
setCenterIndex(displayMode);
m_flowInterface->prepareStartAnimation();
m_flowInterface->runStartAnimation();
@@ -111,7 +117,7 @@
void MostVisitedPagesWidget::updatePos(QPointF pos, qreal &toolBarHeight)
{
QGraphicsWidget::setPos(pos);
- m_flowInterface->setPos(pos.x(), m_parent->size().height() - toolBarHeight - KLinearSnippetHeight);
+ m_flowInterface->setPos(pos.x(), m_parent->size().height() - (toolBarHeight+5) - KLinearSnippetHeight);
}
void MostVisitedPagesWidget::resize(const QSize &size)
@@ -122,12 +128,12 @@
void MostVisitedPagesWidget::displayModeChanged(QString& newMode)
{
- m_flowInterface->displayModeChanged(newMode);
+ m_flowInterface->displayModeChanged(newMode);
}
void MostVisitedPagesWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
- painter->fillRect(0, 0, size().width(), size().height(), QColor(107, 109, 107));
+ painter->fillRect(0, 0, size().width(), size().height(), QColor(255, 255, 255));
QGraphicsWidget::paint(painter, option, widget);
}
@@ -146,7 +152,7 @@
{
Q_ASSERT(m_flowInterface);
m_selectIndex = index;
- close();
+ close();
}
void MostVisitedPagesWidget::closeAnimationCompleted()
@@ -157,14 +163,14 @@
QGraphicsWidget::hide();
disconnect(m_flowInterface, SIGNAL(ok(int)), this, SLOT(okTriggered(int)));
disconnect(m_flowInterface, SIGNAL(endAnimationCplt()), this, SLOT(closeAnimationCompleted()));
- disconnect(m_flowInterface, SIGNAL(mouseEvent(QEvent::Type)),this->m_snippet,SIGNAL(snippetMouseEvent(QEvent::Type)));
+ disconnect(m_flowInterface, SIGNAL(mouseEvent(QEvent::Type)),this,SIGNAL(mouseEvent(QEvent::Type)));
m_flowInterface->removeEventFilter(this);
m_flowInterface->deleteLater();
m_flowInterface = NULL;
-
+
if (m_selectIndex != -1)
- static_cast<ChromeWidget*>(m_parent)->loadUrlToCurrentPage(m_mostVisitedPageStore->pageAt(m_selectIndex)->pageUrl());
+ m_chrome->loadUrlToCurrentPage(m_mostVisitedPageStore->pageAt(m_selectIndex)->pageUrl());
if (m_snippet->isVisible() && m_hideOnClose)
m_snippet->ChromeSnippet::toggleVisibility();
@@ -177,32 +183,27 @@
{
qreal toolBarHeight;
- ChromeSnippet* visibleSnippet= static_cast<ChromeWidget*>(m_parent)->getSnippet("WebViewToolbarId");
+ ChromeSnippet* visibleSnippet= m_chrome->getSnippet("WebViewToolbarId");
if (visibleSnippet)
- toolBarHeight = visibleSnippet->widget()->geometry().height();
+ toolBarHeight = visibleSnippet->widget()->geometry().height();
resize(m_parent->size().toSize());
updatePos(QPointF(0, 0), toolBarHeight);
}
- void MostVisitedPagesWidget::updateMVStore(QWebPage *page)
+ void MostVisitedPagesWidget::updateMVStore(WRT::WrtBrowserContainer *page)
{
Q_ASSERT(page);
Q_ASSERT(!page->mainFrame()->url().isEmpty());
- QImage* pageThumbnail = 0;
QUrl pageUrl = page->mainFrame()->url();
int pageRank = 0;
-
- //check if page exits in store along with its thumbnail
+ QImage* pageThumbnail = NULL;
+ //check if page exists in store along with its thumbnail
if (!m_mostVisitedPageStore->contains(pageUrl.toString(), true)) {
- QSize thumbnailSize(200, 200);
- pageThumbnail = new QImage(thumbnailSize.width(), thumbnailSize.height(), QImage::Format_RGB32);
- QPainter painter(pageThumbnail);
- qreal webcoreScale = page->mainFrame()->zoomFactor();
- painter.scale(1.f / webcoreScale, 1.f / webcoreScale);
- painter.fillRect(0, 0, size().width(), size().height(), QColor(255, 255, 255));
- page->mainFrame()->render(&painter, QWebFrame::AllLayers, QRegion(0, 0, thumbnailSize.width(), thumbnailSize.height()));
+ qreal scale = 200.0 / page->viewportSize().width();
+ QImage img = page->pageThumbnail(scale, scale);
+ pageThumbnail = new QImage(img);
}
//if it is a new page to the store, get its rank from history
@@ -219,5 +220,10 @@
}
}
+void MostVisitedPagesWidget::clearMVStore()
+{
+ m_mostVisitedPageStore->clearMostVisitedPageStore();
+}
+
} // endof namespace GVA