2012-05-14 18:37:22 +00:00
|
|
|
/*
|
2012-05-14 19:16:56 +00:00
|
|
|
* Copyright 2012 by Marco Martin <mart@kde.org>
|
2012-05-14 18:37:22 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2012-10-03 09:32:42 +00:00
|
|
|
* it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2,
|
|
|
|
* or (at your option) any later version.
|
2012-05-14 18:37:22 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-10-03 09:32:42 +00:00
|
|
|
* GNU General Public License for more details
|
2012-05-14 18:37:22 +00:00
|
|
|
*
|
2012-10-03 09:32:42 +00:00
|
|
|
* You should have received a copy of the GNU General Public
|
2012-05-14 18:37:22 +00:00
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pageitem.h"
|
|
|
|
#include "documentitem.h"
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QStyleOptionGraphicsItem>
|
2018-04-18 14:57:27 +00:00
|
|
|
#include <QQuickWindow>
|
2018-04-25 15:25:21 +00:00
|
|
|
#include <QSGSimpleTextureNode>
|
2012-05-14 18:37:22 +00:00
|
|
|
|
2012-08-01 16:14:12 +00:00
|
|
|
#include <core/bookmarkmanager.h>
|
2012-05-15 15:23:15 +00:00
|
|
|
#include <core/document.h>
|
|
|
|
#include <core/generator.h>
|
2012-08-01 16:14:12 +00:00
|
|
|
#include <core/page.h>
|
2012-05-14 18:37:22 +00:00
|
|
|
|
2012-10-02 12:19:09 +00:00
|
|
|
#include "ui/pagepainter.h"
|
2013-02-24 21:58:53 +00:00
|
|
|
#include "ui/priorities.h"
|
2012-05-14 18:37:22 +00:00
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
#define REDRAW_TIMEOUT 250
|
|
|
|
|
2014-12-02 19:41:16 +00:00
|
|
|
PageItem::PageItem(QQuickItem *parent)
|
2018-04-25 15:25:21 +00:00
|
|
|
: QQuickItem(parent),
|
2015-10-29 12:37:11 +00:00
|
|
|
Okular::View( QLatin1String( "PageView" ) ),
|
2017-09-05 21:27:18 +00:00
|
|
|
m_page(nullptr),
|
2012-05-25 19:28:53 +00:00
|
|
|
m_smooth(false),
|
2012-10-07 19:09:15 +00:00
|
|
|
m_bookmarked(false),
|
2013-02-24 21:58:53 +00:00
|
|
|
m_isThumbnail(false)
|
2012-05-14 18:37:22 +00:00
|
|
|
{
|
2014-12-02 19:41:16 +00:00
|
|
|
setFlag(QQuickItem::ItemHasContents, true);
|
2012-05-14 18:37:22 +00:00
|
|
|
|
2012-10-12 10:50:39 +00:00
|
|
|
m_viewPort.rePos.enabled = true;
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
m_redrawTimer = new QTimer(this);
|
2012-10-07 19:09:15 +00:00
|
|
|
m_redrawTimer->setInterval(REDRAW_TIMEOUT);
|
2012-05-14 18:37:22 +00:00
|
|
|
m_redrawTimer->setSingleShot(true);
|
2018-05-13 14:44:40 +00:00
|
|
|
connect(m_redrawTimer, &QTimer::timeout, this, &PageItem::requestPixmap);
|
2018-04-25 23:34:58 +00:00
|
|
|
connect(this, &QQuickItem::windowChanged, m_redrawTimer, [this]() {m_redrawTimer->start(); });
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PageItem::~PageItem()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-02 19:41:16 +00:00
|
|
|
void PageItem::setFlickable(QQuickItem *flickable)
|
2012-10-05 13:59:08 +00:00
|
|
|
{
|
|
|
|
if (m_flickable.data() == flickable) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//check the object can act as a flickable
|
|
|
|
if (!flickable->property("contentX").isValid() ||
|
|
|
|
!flickable->property("contentY").isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_flickable) {
|
2017-09-05 21:27:18 +00:00
|
|
|
disconnect(m_flickable.data(), nullptr, this, nullptr);
|
2012-10-05 13:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//check the object can act as a flickable
|
|
|
|
if (!flickable->property("contentX").isValid() ||
|
|
|
|
!flickable->property("contentY").isValid()) {
|
|
|
|
m_flickable.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_flickable = flickable;
|
|
|
|
|
|
|
|
if (flickable) {
|
|
|
|
connect(flickable, SIGNAL(contentXChanged()), this, SLOT(contentXChanged()));
|
|
|
|
connect(flickable, SIGNAL(contentYChanged()), this, SLOT(contentYChanged()));
|
|
|
|
}
|
|
|
|
|
|
|
|
emit flickableChanged();
|
|
|
|
}
|
|
|
|
|
2014-12-02 19:41:16 +00:00
|
|
|
QQuickItem *PageItem::flickable() const
|
2012-10-05 13:59:08 +00:00
|
|
|
{
|
|
|
|
return m_flickable.data();
|
|
|
|
}
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
DocumentItem *PageItem::document() const
|
|
|
|
{
|
|
|
|
return m_documentItem.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::setDocument(DocumentItem *doc)
|
|
|
|
{
|
|
|
|
if (doc == m_documentItem.data() || !doc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-05 21:27:18 +00:00
|
|
|
m_page = nullptr;
|
|
|
|
disconnect(doc, nullptr, this, nullptr);
|
2012-05-14 18:37:22 +00:00
|
|
|
m_documentItem = doc;
|
2013-02-24 21:58:53 +00:00
|
|
|
Observer *observer = m_isThumbnail ? m_documentItem.data()->thumbnailObserver() : m_documentItem.data()->pageviewObserver();
|
2015-10-29 12:37:11 +00:00
|
|
|
connect(observer, &Observer::pageChanged, this, &PageItem::pageHasChanged);
|
|
|
|
connect(doc->document()->bookmarkManager(), &Okular::BookmarkManager::bookmarksChanged,
|
|
|
|
this, &PageItem::checkBookmarksChanged);
|
2012-05-14 18:37:22 +00:00
|
|
|
setPageNumber(0);
|
|
|
|
emit documentChanged();
|
2012-10-07 19:09:15 +00:00
|
|
|
m_redrawTimer->start();
|
2014-02-14 16:34:13 +00:00
|
|
|
|
2018-05-09 00:45:12 +00:00
|
|
|
connect(doc, &DocumentItem::urlChanged, this, &PageItem::refreshPage);
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PageItem::pageNumber() const
|
|
|
|
{
|
2012-10-05 13:59:08 +00:00
|
|
|
return m_viewPort.pageNumber;
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::setPageNumber(int number)
|
|
|
|
{
|
2012-10-05 13:59:08 +00:00
|
|
|
if ((m_page && m_viewPort.pageNumber == number) ||
|
2012-05-14 18:37:22 +00:00
|
|
|
!m_documentItem ||
|
|
|
|
!m_documentItem.data()->isOpened() ||
|
2018-04-25 13:55:30 +00:00
|
|
|
number < 0) {
|
2012-05-14 18:37:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-05 13:59:08 +00:00
|
|
|
m_viewPort.pageNumber = number;
|
2018-04-25 13:55:30 +00:00
|
|
|
refreshPage();
|
2012-05-14 18:37:22 +00:00
|
|
|
emit pageNumberChanged();
|
2018-04-25 13:55:30 +00:00
|
|
|
checkBookmarksChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::refreshPage()
|
|
|
|
{
|
|
|
|
if (uint(m_viewPort.pageNumber) < m_documentItem.data()->document()->pages()) {
|
|
|
|
m_page = m_documentItem.data()->document()->page(m_viewPort.pageNumber);
|
|
|
|
} else {
|
|
|
|
m_page = nullptr;
|
|
|
|
}
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
emit implicitWidthChanged();
|
|
|
|
emit implicitHeightChanged();
|
2018-04-25 13:55:30 +00:00
|
|
|
|
2012-10-07 19:09:15 +00:00
|
|
|
m_redrawTimer->start();
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PageItem::implicitWidth() const
|
|
|
|
{
|
|
|
|
if (m_page) {
|
|
|
|
return m_page->width();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int PageItem::implicitHeight() const
|
|
|
|
{
|
|
|
|
if (m_page) {
|
|
|
|
return m_page->height();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::setSmooth(const bool smooth)
|
|
|
|
{
|
|
|
|
if (smooth == m_smooth) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_smooth = smooth;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PageItem::smooth() const
|
|
|
|
{
|
|
|
|
return m_smooth;
|
|
|
|
}
|
|
|
|
|
2012-08-01 16:14:12 +00:00
|
|
|
bool PageItem::isBookmarked()
|
|
|
|
{
|
|
|
|
return m_bookmarked;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::setBookmarked(bool bookmarked)
|
|
|
|
{
|
|
|
|
if (!m_documentItem) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bookmarked == m_bookmarked) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bookmarked) {
|
2012-10-12 10:50:39 +00:00
|
|
|
m_documentItem.data()->document()->bookmarkManager()->addBookmark(m_viewPort);
|
2012-08-01 16:14:12 +00:00
|
|
|
} else {
|
2012-10-05 13:59:08 +00:00
|
|
|
m_documentItem.data()->document()->bookmarkManager()->removeBookmark(m_viewPort.pageNumber);
|
2012-08-01 16:14:12 +00:00
|
|
|
}
|
|
|
|
m_bookmarked = bookmarked;
|
|
|
|
emit bookmarkedChanged();
|
|
|
|
}
|
|
|
|
|
2012-10-05 13:59:08 +00:00
|
|
|
QStringList PageItem::bookmarks() const
|
|
|
|
{
|
|
|
|
QStringList list;
|
|
|
|
foreach(const KBookmark &bookmark, m_documentItem.data()->document()->bookmarkManager()->bookmarks(m_viewPort.pageNumber)) {
|
2014-12-02 19:41:16 +00:00
|
|
|
list << bookmark.url().toString();
|
2012-10-05 13:59:08 +00:00
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::goToBookmark(const QString &bookmark)
|
|
|
|
{
|
2015-01-29 19:55:57 +00:00
|
|
|
Okular::DocumentViewport viewPort(QUrl::fromUserInput(bookmark).fragment(QUrl::FullyDecoded));
|
2012-10-05 13:59:08 +00:00
|
|
|
setPageNumber(viewPort.pageNumber);
|
|
|
|
|
|
|
|
//Are we in a flickable?
|
|
|
|
if (m_flickable) {
|
|
|
|
//normalizedX is a proportion, so contentX will be the difference between document and viewport times normalizedX
|
|
|
|
m_flickable.data()->setProperty("contentX", qMax((qreal)0, width() - m_flickable.data()->width()) * viewPort.rePos.normalizedX);
|
|
|
|
|
|
|
|
m_flickable.data()->setProperty("contentY", qMax((qreal)0, height() - m_flickable.data()->height()) * viewPort.rePos.normalizedY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-12 09:05:31 +00:00
|
|
|
QPointF PageItem::bookmarkPosition(const QString &bookmark) const
|
|
|
|
{
|
2015-01-29 19:55:57 +00:00
|
|
|
Okular::DocumentViewport viewPort(QUrl::fromUserInput(bookmark).fragment(QUrl::FullyDecoded));
|
2012-10-12 09:05:31 +00:00
|
|
|
|
|
|
|
if (viewPort.pageNumber != m_viewPort.pageNumber) {
|
|
|
|
return QPointF(-1, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return QPointF(qMax((qreal)0, width() - m_flickable.data()->width()) * viewPort.rePos.normalizedX,
|
|
|
|
qMax((qreal)0, height() - m_flickable.data()->height()) * viewPort.rePos.normalizedY);
|
|
|
|
}
|
|
|
|
|
2012-10-05 13:59:08 +00:00
|
|
|
void PageItem::setBookmarkAtPos(qreal x, qreal y)
|
|
|
|
{
|
|
|
|
Okular::DocumentViewport viewPort(m_viewPort);
|
|
|
|
viewPort.rePos.normalizedX = x;
|
|
|
|
viewPort.rePos.normalizedY = y;
|
|
|
|
|
|
|
|
m_documentItem.data()->document()->bookmarkManager()->addBookmark(viewPort);
|
2012-10-12 10:50:39 +00:00
|
|
|
|
|
|
|
if (!m_bookmarked) {
|
|
|
|
m_bookmarked = true;
|
|
|
|
emit bookmarkedChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
emit bookmarksChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::removeBookmarkAtPos(qreal x, qreal y)
|
|
|
|
{
|
|
|
|
Okular::DocumentViewport viewPort(m_viewPort);
|
|
|
|
viewPort.rePos.enabled = true;
|
|
|
|
viewPort.rePos.normalizedX = x;
|
|
|
|
viewPort.rePos.normalizedY = y;
|
|
|
|
|
|
|
|
m_documentItem.data()->document()->bookmarkManager()->addBookmark(viewPort);
|
|
|
|
|
|
|
|
if (m_bookmarked && m_documentItem.data()->document()->bookmarkManager()->bookmarks(m_viewPort.pageNumber).count() == 0) {
|
|
|
|
m_bookmarked = false;
|
|
|
|
emit bookmarkedChanged();
|
|
|
|
}
|
|
|
|
|
2012-10-05 13:59:08 +00:00
|
|
|
emit bookmarksChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::removeBookmark(const QString &bookmark)
|
|
|
|
{
|
|
|
|
m_documentItem.data()->document()->bookmarkManager()->removeBookmark(bookmark);
|
|
|
|
emit bookmarksChanged();
|
|
|
|
}
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
//Reimplemented
|
|
|
|
void PageItem::geometryChanged(const QRectF &newGeometry,
|
|
|
|
const QRectF &oldGeometry)
|
|
|
|
{
|
|
|
|
if (newGeometry.size().isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-25 13:56:16 +00:00
|
|
|
bool changed = false;
|
2012-05-25 19:28:53 +00:00
|
|
|
if (newGeometry.size() != oldGeometry.size()) {
|
2018-04-25 13:56:16 +00:00
|
|
|
changed = true;
|
2012-10-07 19:09:15 +00:00
|
|
|
m_redrawTimer->start();
|
2012-05-25 19:28:53 +00:00
|
|
|
}
|
2012-05-14 18:37:22 +00:00
|
|
|
|
2014-12-02 19:41:16 +00:00
|
|
|
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
2018-04-25 13:56:16 +00:00
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
//Why aren't they automatically emuitted?
|
|
|
|
emit widthChanged();
|
|
|
|
emit heightChanged();
|
|
|
|
}
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 15:25:21 +00:00
|
|
|
QSGNode * PageItem::updatePaintNode(QSGNode* node, QQuickItem::UpdatePaintNodeData* /*data*/)
|
2012-05-14 18:37:22 +00:00
|
|
|
{
|
2018-04-25 15:25:21 +00:00
|
|
|
if (!window() || m_buffer.isNull()) {
|
|
|
|
delete node;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
QSGSimpleTextureNode *n = static_cast<QSGSimpleTextureNode *>(node);
|
|
|
|
if (!n) {
|
|
|
|
n = new QSGSimpleTextureNode();
|
|
|
|
n->setOwnsTexture(true);
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 15:25:21 +00:00
|
|
|
n->setTexture(window()->createTextureFromImage(m_buffer));
|
|
|
|
n->setRect(boundingRect());
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2018-05-13 14:44:40 +00:00
|
|
|
void PageItem::requestPixmap()
|
2018-04-25 15:25:21 +00:00
|
|
|
{
|
2018-05-13 14:11:55 +00:00
|
|
|
if (!m_documentItem || !m_page || !window() || width() <= 0 || height() < 0) {
|
|
|
|
if (!m_buffer.isNull()) {
|
|
|
|
m_buffer = QImage();
|
|
|
|
update();
|
|
|
|
}
|
2018-04-25 15:25:21 +00:00
|
|
|
return;
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
2013-02-24 21:58:53 +00:00
|
|
|
Observer *observer = m_isThumbnail ? m_documentItem.data()->thumbnailObserver() : m_documentItem.data()->pageviewObserver();
|
|
|
|
const int priority = m_isThumbnail ? THUMBNAILS_PRIO : PAGEVIEW_PRIO;
|
2012-05-22 14:08:03 +00:00
|
|
|
|
2018-05-13 14:44:40 +00:00
|
|
|
const qreal dpr = window()->devicePixelRatio();
|
2018-04-18 14:57:27 +00:00
|
|
|
|
2018-05-13 14:44:40 +00:00
|
|
|
// Here we want to request the pixmap for the page, but it may happen that the page
|
|
|
|
// already has the pixmap, thus requestPixmaps would not trigger pageHasChanged
|
|
|
|
// and we would not call paint. Always call paint, if we don't have a pixmap
|
|
|
|
// it's a noop. Requesting a page that already has a pixmap is also
|
|
|
|
// almost a noop.
|
|
|
|
// Ideally we would do one or the other but for now this is good enough
|
|
|
|
paint();
|
2018-04-25 23:31:19 +00:00
|
|
|
{
|
2018-05-13 14:44:40 +00:00
|
|
|
auto request = new Okular::PixmapRequest(observer, m_viewPort.pageNumber, width() * dpr, height() * dpr, priority, Okular::PixmapRequest::Asynchronous);
|
2018-05-13 14:11:33 +00:00
|
|
|
request->setNormalizedRect(Okular::NormalizedRect(0,0,1,1));
|
2018-05-13 14:44:40 +00:00
|
|
|
const Okular::Document::PixmapRequestFlag prf = Okular::Document::NoOption;
|
2018-04-25 10:49:53 +00:00
|
|
|
m_documentItem.data()->document()->requestPixmaps({request}, prf);
|
2012-05-25 19:28:53 +00:00
|
|
|
}
|
2018-05-13 14:44:40 +00:00
|
|
|
}
|
2018-04-25 23:32:27 +00:00
|
|
|
|
2018-05-13 14:44:40 +00:00
|
|
|
void PageItem::paint()
|
|
|
|
{
|
|
|
|
Observer *observer = m_isThumbnail ? m_documentItem.data()->thumbnailObserver() : m_documentItem.data()->pageviewObserver();
|
|
|
|
const int flags = PagePainter::Accessibility | PagePainter::Highlights | PagePainter::Annotations;
|
2018-04-25 15:25:21 +00:00
|
|
|
|
2018-05-13 14:44:40 +00:00
|
|
|
const qreal dpr = window()->devicePixelRatio();
|
2018-04-25 23:32:27 +00:00
|
|
|
const QRect limits(QPoint(0, 0), QSize(width()*dpr, height()*dpr));
|
|
|
|
QPixmap pix(limits.size());
|
2018-04-18 14:57:27 +00:00
|
|
|
pix.setDevicePixelRatio(dpr);
|
|
|
|
QPainter p(&pix);
|
2018-04-25 15:25:21 +00:00
|
|
|
p.setRenderHint(QPainter::Antialiasing, m_smooth);
|
2018-04-18 14:57:27 +00:00
|
|
|
PagePainter::paintPageOnPainter(&p, m_page, observer, flags, width(), height(), limits);
|
|
|
|
p.end();
|
2012-05-14 18:37:22 +00:00
|
|
|
|
2018-04-25 15:25:21 +00:00
|
|
|
m_buffer = pix.toImage();
|
|
|
|
|
|
|
|
update();
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Protected slots
|
2012-10-07 19:09:09 +00:00
|
|
|
void PageItem::pageHasChanged(int page, int flags)
|
2012-05-14 18:37:22 +00:00
|
|
|
{
|
2012-10-05 13:59:08 +00:00
|
|
|
if (m_viewPort.pageNumber == page) {
|
2018-05-13 14:44:40 +00:00
|
|
|
if (flags == Okular::DocumentObserver::BoundingBox) {
|
2012-10-07 19:09:09 +00:00
|
|
|
// skip bounding box updates
|
2014-09-11 00:03:46 +00:00
|
|
|
//kDebug() << "32" << m_page->boundingBox();
|
2012-10-07 19:09:09 +00:00
|
|
|
} else if (flags == Okular::DocumentObserver::Pixmap) {
|
|
|
|
// if pixmaps have updated, just repaint .. don't bother updating pixmaps AGAIN
|
2018-05-13 14:44:40 +00:00
|
|
|
paint();
|
2012-10-07 19:09:09 +00:00
|
|
|
} else {
|
|
|
|
m_redrawTimer->start();
|
|
|
|
}
|
2012-05-22 14:03:34 +00:00
|
|
|
}
|
2012-05-14 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 16:14:12 +00:00
|
|
|
void PageItem::checkBookmarksChanged()
|
|
|
|
{
|
|
|
|
if (!m_documentItem) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-05 13:59:08 +00:00
|
|
|
bool newBookmarked = m_documentItem.data()->document()->bookmarkManager()->isBookmarked(m_viewPort.pageNumber);
|
2012-08-01 16:14:12 +00:00
|
|
|
if (m_bookmarked != newBookmarked) {
|
|
|
|
m_bookmarked = newBookmarked;
|
|
|
|
emit bookmarkedChanged();
|
|
|
|
}
|
2012-10-05 13:59:08 +00:00
|
|
|
|
|
|
|
//TODO: check the page
|
|
|
|
emit bookmarksChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::contentXChanged()
|
|
|
|
{
|
|
|
|
if (!m_flickable || !m_flickable.data()->property("contentX").isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-12 10:50:39 +00:00
|
|
|
m_viewPort.rePos.normalizedX = m_flickable.data()->property("contentX").toReal() / (width() - m_flickable.data()->width());
|
2012-10-05 13:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageItem::contentYChanged()
|
|
|
|
{
|
|
|
|
if (!m_flickable || !m_flickable.data()->property("contentY").isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-12 10:50:39 +00:00
|
|
|
m_viewPort.rePos.normalizedY = m_flickable.data()->property("contentY").toReal() / (height() - m_flickable.data()->height());
|
2012-08-01 16:14:12 +00:00
|
|
|
}
|
|
|
|
|
2012-10-07 19:07:38 +00:00
|
|
|
void PageItem::setIsThumbnail(bool thumbnail)
|
|
|
|
{
|
2013-02-24 21:58:53 +00:00
|
|
|
if (thumbnail == m_isThumbnail) {
|
2012-10-07 19:07:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-24 21:58:53 +00:00
|
|
|
m_isThumbnail = thumbnail;
|
2012-10-07 19:07:38 +00:00
|
|
|
|
|
|
|
if (thumbnail) {
|
|
|
|
m_smooth = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
m_redrawTimer->setInterval(thumbnail ? 0 : REDRAW_TIMEOUT);
|
|
|
|
m_redrawTimer->setSingleShot(true);
|
|
|
|
*/
|
|
|
|
}
|