~ubuntu-branches/ubuntu/precise/okular/precise-proposed

« back to all changes in this revision

Viewing changes to ui/pageview.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-12-23 22:53:33 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20111223225333-l6ekbg2vq4pcsvwg
Tags: 4:4.7.95-0ubuntu1
* New upstream release candidate
* Enable DebianABIManager and bump ABI of libokularcore1

Show diffs side-by-side

added added

removed removed

Lines of Context:
863
863
        // update the mouse cursor when closing because we may have close through a link and
864
864
        // want the cursor to come back to the normal cursor
865
865
        updateCursor( contentAreaPosition() + viewport()->mapFromGlobal( QCursor::pos() ) );
866
 
        // then, make the message window and scrollbars disappear, which triggers a repaint
 
866
        // then, make the message window and scrollbars disappear, and trigger a repaint
867
867
        d->messageWindow->hide();
868
868
        resizeContentArea( QSize( 0,0 ) );
 
869
        viewport()->update(); // when there is no change to the scrollbars, no repaint would
 
870
                              // be done and the old document would still be shown
869
871
    }
870
872
 
871
873
    // OSD to display pages
3638
3640
 
3639
3641
    // handle the 'center first page in row' stuff
3640
3642
    int nCols = viewColumns();
3641
 
    bool centerFirstPage = Okular::Settings::viewMode() == Okular::Settings::EnumViewMode::FacingFirstCentered;
 
3643
    const bool centerFirstPage = Okular::Settings::viewMode() == Okular::Settings::EnumViewMode::FacingFirstCentered;
 
3644
    const bool centerLastPage = centerFirstPage && d->items.count() % 2 == 0;
3642
3645
    const bool continuousView = Okular::Settings::viewContinuous();
 
3646
    const bool facingPages = centerFirstPage || Okular::Settings::viewMode() == Okular::Settings::EnumViewMode::Facing;
3643
3647
 
3644
3648
    // set all items geometry and resize contents. handle 'continuous' and 'single' modes separately
3645
3649
 
3721
3725
            if ( continuousView || rIdx == pageRowIdx )
3722
3726
            {
3723
3727
                const bool reallyDoCenterFirst = item->pageNumber() == 0 && centerFirstPage;
3724
 
                item->moveTo( (reallyDoCenterFirst ? 0 : insertX) + ( (reallyDoCenterFirst ? fullWidth : cWidth) - item->croppedWidth()) / 2,
 
3728
                const bool reallyDoCenterLast = item->pageNumber() == d->items.count() - 1 && centerLastPage;
 
3729
                int actualX = 0;
 
3730
                if ( reallyDoCenterFirst || reallyDoCenterLast )
 
3731
                {
 
3732
                    // page is centered across entire viewport
 
3733
                    actualX = (fullWidth - item->croppedWidth()) / 2;
 
3734
                }
 
3735
                else if ( facingPages )
 
3736
                {
 
3737
                    // page edges 'touch' the center of the viewport
 
3738
                    actualX = ( (centerFirstPage && item->pageNumber() % 2 == 1) ||
 
3739
                                (!centerFirstPage && item->pageNumber() % 2 == 0) ) ?
 
3740
                        (fullWidth / 2) - item->croppedWidth() - 1 : (fullWidth / 2) + 1;
 
3741
                }
 
3742
                else
 
3743
                {
 
3744
                    // page is centered within its virtual column
 
3745
                    actualX = insertX + (cWidth - item->croppedWidth()) / 2;
 
3746
                }
 
3747
                item->moveTo( actualX,
3725
3748
                              (continuousView ? insertY : origInsertY) + (rHeight - item->croppedHeight()) / 2 );
3726
3749
                item->setVisible( true );
3727
3750
            }
3804
3827
         d->mouseMidZooming )
3805
3828
        return;
3806
3829
 
3807
 
    // precalc view limits for intersecting with page coords inside the lOOp
3808
 
    bool isEvent = newValue != -1 && !d->blockViewport;
3809
 
    QRect viewportRect( horizontalScrollBar()->value(),
3810
 
                        verticalScrollBar()->value(),
3811
 
                        viewport()->width(), viewport()->height() );
 
3830
    // precalc view limits for intersecting with page coords inside the loop
 
3831
    const bool isEvent = newValue != -1 && !d->blockViewport;
 
3832
    const QRect viewportRect( horizontalScrollBar()->value(),
 
3833
                              verticalScrollBar()->value(),
 
3834
                              viewport()->width(), viewport()->height() );
 
3835
    const QRect viewportRectAtZeroZero( 0, 0, viewport()->width(), viewport()->height() );
3812
3836
 
3813
3837
    // some variables used to determine the viewport
3814
3838
    int nearPageNumber = -1;
3815
 
    double viewportCenterX = (viewportRect.left() + viewportRect.right()) / 2.0,
3816
 
           viewportCenterY = (viewportRect.top() + viewportRect.bottom()) / 2.0,
3817
 
           focusedX = 0.5,
 
3839
    const double viewportCenterX = (viewportRect.left() + viewportRect.right()) / 2.0;
 
3840
    const double viewportCenterY = (viewportRect.top() + viewportRect.bottom()) / 2.0;
 
3841
    double focusedX = 0.5,
3818
3842
           focusedY = 0.0,
3819
3843
           minDistance = -1.0;
3820
3844
 
3839
3863
            vw->move(
3840
3864
                qRound( i->uncroppedGeometry().left() + i->uncroppedWidth() * r.left ) + 1 - viewportRect.left(),
3841
3865
                qRound( i->uncroppedGeometry().top() + i->uncroppedHeight() * r.top ) + 1 - viewportRect.top() );
 
3866
            
 
3867
            if ( vw->isPlaying() && viewportRectAtZeroZero.intersect( vw->geometry() ).isEmpty() ) {
 
3868
                vw->stop();
 
3869
            }
3842
3870
        }
3843
3871
 
3844
3872
        if ( !i->isVisible() )
4341
4369
    d->document->processAction( action );
4342
4370
}
4343
4371
 
4344
 
void PageView::slotFormFieldChanged( Okular::FormField *ff )
4345
 
{
4346
 
    QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd();
4347
 
    for ( ; dIt != dEnd; ++dIt )
4348
 
    {
4349
 
        FormWidgetIface *fw = (*dIt)->formWidgets().value( ff->id() );
4350
 
        if (fw != NULL)
4351
 
        {
4352
 
            switch (ff->type()) {
4353
 
                case Okular::FormField::FormText: {
4354
 
                    Okular::FormFieldText* fft = static_cast<Okular::FormFieldText *>(ff);
4355
 
                    FormLineEdit *le = dynamic_cast<FormLineEdit *>(fw);
4356
 
                    TextAreaEdit *te = dynamic_cast<TextAreaEdit *>(fw);
4357
 
 
4358
 
                    if (le) le->setText( fft->text() );
4359
 
                    if (te) te->setText( fft->text() );
4360
 
                } break;
4361
 
       
4362
 
                case Okular::FormField::FormButton: {
4363
 
                    Okular::FormFieldButton* ffb = static_cast<Okular::FormFieldButton *>(ff);
4364
 
                    QAbstractButton *be = dynamic_cast<QAbstractButton *>(fw);
4365
 
                    if (be) be->setChecked( ffb->state() );
4366
 
                } break;
4367
 
       
4368
 
                default:
4369
 
                    kDebug() << "Unhandled form field: " << ff->name() << ff->defaultValue();
4370
 
                break;
4371
 
            }
4372
 
            
4373
 
            break; // Found the widget, no need to loop more pages
4374
 
        }
4375
 
    }
4376
 
}
4377
 
 
4378
4372
void PageView::externalKeyPressEvent( QKeyEvent *e )
4379
4373
{
4380
4374
    keyPressEvent( e );