diff options
author | unknown <Roopesh Chander@.(none)> | 2009-11-12 18:28:42 +0530 |
---|---|---|
committer | unknown <Roopesh Chander@.(none)> | 2009-11-12 18:28:45 +0530 |
commit | f32b5bb5f1e4ed79d420b9e97970ef0e7acf1687 (patch) | |
tree | 9d66a8dd8513db6167ce0aaa9b52bfb17211d722 /webscrap.cpp | |
parent | c806601e0f8a7c81aeb2321bf331090011c187b2 (diff) |
initialize page viewport and geometry on creation.
change geometry only when required.
the added scrap's initial scroll position is now accurate.
Diffstat (limited to 'webscrap.cpp')
-rw-r--r-- | webscrap.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/webscrap.cpp b/webscrap.cpp index 61414a3..156c96c 100644 --- a/webscrap.cpp +++ b/webscrap.cpp @@ -14,10 +14,12 @@ const int WebScrapContainer::s_titlePadding = 25; // padding on the top of the scrap const int WebScrapContainer::s_padding = 2; // padding on the other three sides -WebScrap::WebScrap(QUrl url, QRect scrapRect, QGraphicsItem * parent) +WebScrap::WebScrap(QUrl url, QSize pageSize, QRect scrapRect, QGraphicsItem * parent) : QGraphicsWebView(parent) , m_isLoading(false) { + setGeometry(QRectF(pos(), scrapRect.size())); + page()->setViewportSize(pageSize); setScrapRect(scrapRect); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); @@ -52,7 +54,6 @@ WebScrap::WebScrap(QUrl url, QRect scrapRect, QGraphicsItem * parent) void WebScrap::setScrapRect(QRect r) { m_scrapRect = r; - setGeometry(QRectF(pos(), r.size())); if (! m_isLoading) page()->mainFrame()->setScrollPosition(scrapRect().topLeft()); } @@ -115,7 +116,6 @@ void WebScrap::onLoadStarted() { void WebScrap::onLoadFinished() { page()->mainFrame()->setScrollPosition(scrapRect().topLeft()); - page()->setViewportSize(pageSize()); m_isLoading = false; update(); } @@ -465,6 +465,7 @@ void WebScrapContainer::handleRectResized(QRectF rect) { QRect scrapRect = rect.toRect(); scrapRect.moveTopLeft(m_scrap->scrapRect().topLeft()); m_scrap->setScrapRect(scrapRect); + m_scrap->setGeometry(QRectF(m_scrap->pos(), scrapRect.size())); } QSize scrapSize = QSize(rect.width() * m_scrapScale->xScale(), rect.height() * m_scrapScale->yScale()); setGeometry(geometry().left(), geometry().top(), scrapSize.width() + s_padding * 2, scrapSize.height() + s_titlePadding + s_padding); |