~adamreichold/qpdfview/trunk

« back to all changes in this revision

Viewing changes to sources/pageitem.cpp

  • Committer: Adam Reichold
  • Date: 2014-03-29 10:20:32 UTC
  • Revision ID: adam.reichold@t-online.com-20140329102032-6z5yl9a2fkwm62rd
Make proper use of application and anonymous namespaces and fix a few header guards.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "model.h"
40
40
#include "rendertask.h"
41
41
 
 
42
namespace qpdfview
 
43
{
 
44
 
42
45
Settings* PageItem::s_settings = 0;
43
46
 
44
47
QCache< PageItem*, QPixmap > PageItem::s_cache;
45
48
 
46
 
PageItem::PageItem(Model::Page* page, int index, bool presentationMode, QGraphicsItem* parent) : QGraphicsObject(parent),
 
49
PageItem::PageItem(model::Page* page, int index, bool presentationMode, QGraphicsItem* parent) : QGraphicsObject(parent),
47
50
    m_page(0),
48
51
    m_index(-1),
49
52
    m_size(),
294
297
    m_obsoletePixmap = QPixmap();
295
298
}
296
299
 
297
 
void PageItem::showAnnotationOverlay(Model::Annotation* selectedAnnotation)
 
300
void PageItem::showAnnotationOverlay(model::Annotation* selectedAnnotation)
298
301
{
299
302
    if(s_settings->pageItem().annotationOverlay())
300
303
    {
319
322
    updateOverlay(m_annotationOverlay);
320
323
}
321
324
 
322
 
void PageItem::showFormFieldOverlay(Model::FormField* selectedFormField)
 
325
void PageItem::showFormFieldOverlay(model::FormField* selectedFormField)
323
326
{
324
327
    if(s_settings->pageItem().formFieldOverlay())
325
328
    {
354
357
    {
355
358
        // links
356
359
 
357
 
        foreach(const Model::Link* link, m_links)
 
360
        foreach(const model::Link* link, m_links)
358
361
        {
359
362
            if(m_normalizedTransform.map(link->boundary).contains(event->pos()))
360
363
            {
393
396
 
394
397
        // annotations
395
398
 
396
 
        foreach(const Model::Annotation* annotation, m_annotations)
 
399
        foreach(const model::Annotation* annotation, m_annotations)
397
400
        {
398
401
            if(m_normalizedTransform.mapRect(annotation->boundary()).contains(event->pos()))
399
402
            {
406
409
 
407
410
        // form fields
408
411
 
409
 
        foreach(const Model::FormField* formField, m_formFields)
 
412
        foreach(const model::FormField* formField, m_formFields)
410
413
        {
411
414
            if(m_normalizedTransform.mapRect(formField->boundary()).contains(event->pos()))
412
415
            {
469
472
    {
470
473
        // links
471
474
 
472
 
        foreach(const Model::Link* link, m_links)
 
475
        foreach(const model::Link* link, m_links)
473
476
        {
474
477
            if(m_normalizedTransform.map(link->boundary).contains(event->pos()))
475
478
            {
507
510
 
508
511
        // annotations
509
512
 
510
 
        foreach(Model::Annotation* annotation, m_annotations)
 
513
        foreach(model::Annotation* annotation, m_annotations)
511
514
        {
512
515
            if(m_normalizedTransform.mapRect(annotation->boundary()).contains(event->pos()))
513
516
            {
524
527
 
525
528
        // form fields
526
529
 
527
 
        foreach(Model::FormField* formField, m_formFields)
 
530
        foreach(model::FormField* formField, m_formFields)
528
531
        {
529
532
            if(m_normalizedTransform.mapRect(formField->boundary()).contains(event->pos()))
530
533
            {
611
614
        return;
612
615
    }
613
616
 
614
 
    foreach(Model::Annotation* annotation, m_annotations)
 
617
    foreach(model::Annotation* annotation, m_annotations)
615
618
    {
616
619
        if(m_normalizedTransform.mapRect(annotation->boundary()).contains(event->pos()))
617
620
        {
635
638
    {
636
639
        m_annotations = m_page->annotations();
637
640
 
638
 
        foreach(const Model::Annotation* annotation, m_annotations)
 
641
        foreach(const model::Annotation* annotation, m_annotations)
639
642
        {
640
643
            connect(annotation, SIGNAL(wasModified()), SIGNAL(wasModified()));
641
644
        }
642
645
 
643
646
        m_formFields = m_page->formFields();
644
647
 
645
 
        foreach(const Model::FormField* formField, m_formFields)
 
648
        foreach(const model::FormField* formField, m_formFields)
646
649
        {
647
650
            connect(formField, SIGNAL(wasModified()), SIGNAL(wasModified()));
648
651
        }
719
722
        {
720
723
            QRectF boundary = m_normalizedTransform.inverted().mapRect(m_rubberBand);
721
724
 
722
 
            Model::Annotation* annotation = 0;
 
725
            model::Annotation* annotation = 0;
723
726
 
724
727
            if(action == addTextAction)
725
728
            {
744
747
    }
745
748
}
746
749
 
747
 
void PageItem::removeAnnotation(Model::Annotation* annotation, const QPoint& screenPos)
 
750
void PageItem::removeAnnotation(model::Annotation* annotation, const QPoint& screenPos)
748
751
{
749
752
    if(m_page->canAddAndRemoveAnnotations())
750
753
    {
845
848
    }
846
849
}
847
850
 
848
 
void PageItem::setProxyGeometry(Model::Annotation* annotation, QGraphicsProxyWidget* proxy) const
 
851
void PageItem::setProxyGeometry(model::Annotation* annotation, QGraphicsProxyWidget* proxy) const
849
852
{
850
853
    const QPointF center = m_normalizedTransform.map(annotation->boundary().center());
851
854
 
863
866
    proxy->setGeometry(QRectF(x, y, width, height));
864
867
}
865
868
 
866
 
void PageItem::setProxyGeometry(Model::FormField* formField, QGraphicsProxyWidget* proxy) const
 
869
void PageItem::setProxyGeometry(model::FormField* formField, QGraphicsProxyWidget* proxy) const
867
870
{
868
871
    QRectF rect = m_normalizedTransform.mapRect(formField->boundary());
869
872
 
1048
1051
        painter->setTransform(m_normalizedTransform, true);
1049
1052
        painter->setPen(QPen(Qt::red, 0.0));
1050
1053
 
1051
 
        foreach(const Model::Link* link, m_links)
 
1054
        foreach(const model::Link* link, m_links)
1052
1055
        {
1053
1056
            painter->drawPath(link->boundary);
1054
1057
        }
1066
1069
        painter->setTransform(m_normalizedTransform, true);
1067
1070
        painter->setPen(QPen(Qt::blue, 0.0));
1068
1071
 
1069
 
        foreach(const Model::FormField* formField, m_formFields)
 
1072
        foreach(const model::FormField* formField, m_formFields)
1070
1073
        {
1071
1074
            painter->drawRect(formField->boundary());
1072
1075
        }
1110
1113
    }
1111
1114
}
1112
1115
 
1113
 
ThumbnailItem::ThumbnailItem(Model::Page* page, int index, QGraphicsItem* parent) : PageItem(page, index, false, parent),
 
1116
ThumbnailItem::ThumbnailItem(model::Page* page, int index, QGraphicsItem* parent) : PageItem(page, index, false, parent),
1114
1117
#if QT_VERSION >= QT_VERSION_CHECK(4,7,0)
1115
1118
    m_text(QString::number(index + 1)),
1116
1119
#endif // QT_VERSION
1257
1260
 
1258
1261
    setToolTip(QString("%1 mm x %2 mm%3").arg(width, 0, 'f', 1).arg(height, 0, 'f', 1).arg(paperSize));
1259
1262
}
 
1263
 
 
1264
} // qpdfview