~ubuntu-branches/ubuntu/vivid/qpdfview/vivid

« back to all changes in this revision

Viewing changes to sources/documentlayout.cpp

  • Committer: Package Import Robot
  • Author(s): Benjamin Eltzner
  • Date: 2014-10-22 21:49:15 UTC
  • mfrom: (1.2.15)
  • Revision ID: package-import@ubuntu.com-20141022214915-agqeoe318lzs2s4d
Tags: 0.4.12-1
* New upstream release.
* Fixed option to zoom to selection and implemented tiled rendering
  (Closes: #739554)
* Enable support for qt5 and poppler-qt5.
* Explicit dependence on hicolor-icon-theme.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 
3
 
Copyright 2013 Adam Reichold
 
3
Copyright 2014 S. Razi Alavizadeh
 
4
Copyright 2013-2014 Adam Reichold
4
5
 
5
6
This file is part of qpdfview.
6
7
 
49
50
    }
50
51
}
51
52
 
 
53
bool DocumentLayout::isCurrentPage(const QRectF& visibleRect, const QRectF& pageRect) const
 
54
{
 
55
    // Works with vertically scrolling layouts, i.e. all currently implemented layouts.
 
56
    const qreal pageVisibleHeight = pageRect.intersected(visibleRect).height();
 
57
    const qreal pageTopOffset = pageRect.top() - visibleRect.top();
 
58
 
 
59
    if(visibleRect.height() > 2.0 * pageRect.height()) // Are more than two pages visible?
 
60
    {
 
61
        const qreal halfPageHeight = pageRect.height() / 2.0;
 
62
 
 
63
        return pageVisibleHeight >= halfPageHeight && pageTopOffset < halfPageHeight && pageTopOffset >= -halfPageHeight;
 
64
    }
 
65
    else
 
66
    {
 
67
        return pageVisibleHeight >= visibleRect.height() / 2.0;
 
68
    }
 
69
}
 
70
 
52
71
qreal DocumentLayout::visibleHeight(int viewportHeight) const
53
72
{
54
73
    const qreal pageSpacing = s_settings->documentView().pageSpacing();
99
118
    return viewportWidth - 6.0 - 2.0 * pageSpacing;
100
119
}
101
120
 
102
 
void SinglePageLayout::prepareLayout(const QVector<PageItem *>& pageItems, bool /* rightToLeft */,
103
 
                                     QMap< qreal, int >& heightToIndex, qreal& left, qreal& right, qreal& height)
 
121
void SinglePageLayout::prepareLayout(const QVector< PageItem* >& pageItems, bool /* rightToLeft */,
 
122
                                     qreal& left, qreal& right, qreal& height)
104
123
{
105
124
    const qreal pageSpacing = s_settings->documentView().pageSpacing();
106
125
    qreal pageHeight = 0.0;
112
131
 
113
132
        page->setPos(-boundingRect.left() - 0.5 * boundingRect.width(), height - boundingRect.top());
114
133
 
115
 
        heightToIndex.insert(-height + pageSpacing + 0.3 * pageHeight, index);
116
 
 
117
134
        pageHeight = boundingRect.height();
118
135
 
119
136
        left = qMin(left, -0.5f * boundingRect.width() - pageSpacing);
163
180
    return (viewportWidth - 6.0 - 3 * pageSpacing) / 2;
164
181
}
165
182
 
166
 
void TwoPagesLayout::prepareLayout(const QVector<PageItem *>& pageItems, bool rightToLeft,
167
 
                                   QMap< qreal, int >& heightToIndex, qreal& left, qreal& right, qreal& height)
 
183
void TwoPagesLayout::prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft,
 
184
                                   qreal& left, qreal& right, qreal& height)
168
185
{
169
186
    const qreal pageSpacing = s_settings->documentView().pageSpacing();
170
187
    qreal pageHeight = 0.0;
181
198
        {
182
199
            page->setPos(rightToLeft ? rightPos : leftPos, height - boundingRect.top());
183
200
 
184
 
            heightToIndex.insert(-height + pageSpacing + 0.3 * pageHeight, index);
185
 
 
186
201
            pageHeight = boundingRect.height();
187
202
 
188
203
            if(rightToLeft)
290
305
}
291
306
 
292
307
void MultiplePagesLayout::prepareLayout(const QVector< PageItem* >& pageItems, bool rightToLeft,
293
 
                                        QMap< qreal, int >& heightToIndex, qreal& left, qreal& right, qreal& height)
 
308
                                        qreal& left, qreal& right, qreal& height)
294
309
{
295
310
    const qreal pageSpacing = s_settings->documentView().pageSpacing();
296
311
    qreal pageHeight = 0.0;
316
331
            left += boundingRect.width() + pageSpacing;
317
332
        }
318
333
 
319
 
        if(index == leftIndex(index))
320
 
        {
321
 
            heightToIndex.insert(-height + pageSpacing + 0.3 * pageHeight, index);
322
 
        }
323
 
 
324
334
        if(index == rightIndex(index, pageItems.count()))
325
335
        {
326
336
            height += pageHeight + pageSpacing;