Changeset View
Changeset View
Standalone View
Standalone View
core/documentcommands.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | Okular::NormalizedRect buildBoundingRectangleForButtons( const QList<Okular::FormFieldButton*> & formButtons ) | 44 | Okular::NormalizedRect buildBoundingRectangleForButtons( const QList<Okular::FormFieldButton*> & formButtons ) | ||
45 | { | 45 | { | ||
46 | // Initialize coordinates of the bounding rect | 46 | // Initialize coordinates of the bounding rect | ||
47 | double left = 1.0; | 47 | double left = 1.0; | ||
48 | double top = 1.0; | 48 | double top = 1.0; | ||
49 | double right = 0.0; | 49 | double right = 0.0; | ||
50 | double bottom = 0.0; | 50 | double bottom = 0.0; | ||
51 | 51 | | |||
52 | foreach( FormFieldButton* formButton, formButtons ) | 52 | for( const FormFieldButton *formButton : formButtons ) | ||
53 | { | 53 | { | ||
54 | left = qMin<double>( left, formButton->rect().left ); | 54 | left = qMin<double>( left, formButton->rect().left ); | ||
55 | top = qMin<double>( top, formButton->rect().top ); | 55 | top = qMin<double>( top, formButton->rect().top ); | ||
56 | right = qMax<double>( right, formButton->rect().right ); | 56 | right = qMax<double>( right, formButton->rect().right ); | ||
57 | bottom = qMax<double>( bottom, formButton->rect().bottom ); | 57 | bottom = qMax<double>( bottom, formButton->rect().bottom ); | ||
58 | } | 58 | } | ||
59 | Okular::NormalizedRect boundingRect( left, top, right, bottom ); | 59 | Okular::NormalizedRect boundingRect( left, top, right, bottom ); | ||
60 | return boundingRect; | 60 | return boundingRect; | ||
▲ Show 20 Lines • Show All 622 Lines • ▼ Show 20 Line(s) | 680 | EditFormButtonsCommand::EditFormButtonsCommand( Okular::DocumentPrivate* docPriv, | |||
683 | const QList< bool > & newButtonStates ) | 683 | const QList< bool > & newButtonStates ) | ||
684 | : m_docPriv( docPriv ), | 684 | : m_docPriv( docPriv ), | ||
685 | m_pageNumber( pageNumber ), | 685 | m_pageNumber( pageNumber ), | ||
686 | m_formButtons( formButtons ), | 686 | m_formButtons( formButtons ), | ||
687 | m_newButtonStates( newButtonStates ), | 687 | m_newButtonStates( newButtonStates ), | ||
688 | m_prevButtonStates( QList< bool >() ) | 688 | m_prevButtonStates( QList< bool >() ) | ||
689 | { | 689 | { | ||
690 | setText( i18nc( "Edit the state of a group of form buttons", "edit form button states" ) ); | 690 | setText( i18nc( "Edit the state of a group of form buttons", "edit form button states" ) ); | ||
691 | foreach( FormFieldButton* formButton, m_formButtons ) | 691 | for ( const FormFieldButton *formButton : qAsConst(m_formButtons) ) | ||
692 | { | 692 | { | ||
693 | m_prevButtonStates.append( formButton->state() ); | 693 | m_prevButtonStates.append( formButton->state() ); | ||
694 | } | 694 | } | ||
695 | } | 695 | } | ||
696 | 696 | | |||
697 | void EditFormButtonsCommand::undo() | 697 | void EditFormButtonsCommand::undo() | ||
698 | { | 698 | { | ||
699 | clearFormButtonStates(); | 699 | clearFormButtonStates(); | ||
Show All 25 Lines | 714 | { | |||
725 | emit m_docPriv->m_parent->formButtonsChangedByUndoRedo( m_pageNumber, m_formButtons ); | 725 | emit m_docPriv->m_parent->formButtonsChangedByUndoRedo( m_pageNumber, m_formButtons ); | ||
726 | m_docPriv->notifyFormChanges( m_pageNumber ); | 726 | m_docPriv->notifyFormChanges( m_pageNumber ); | ||
727 | } | 727 | } | ||
728 | 728 | | |||
729 | bool EditFormButtonsCommand::refreshInternalPageReferences( const QVector< Okular::Page * > &newPagesVector ) | 729 | bool EditFormButtonsCommand::refreshInternalPageReferences( const QVector< Okular::Page * > &newPagesVector ) | ||
730 | { | 730 | { | ||
731 | const QList< FormFieldButton* > oldFormButtons = m_formButtons; | 731 | const QList< FormFieldButton* > oldFormButtons = m_formButtons; | ||
732 | m_formButtons.clear(); | 732 | m_formButtons.clear(); | ||
733 | foreach( FormFieldButton* oldFormButton, oldFormButtons ) | 733 | for ( FormFieldButton *oldFormButton : oldFormButtons ) | ||
734 | { | 734 | { | ||
735 | FormFieldButton *button = dynamic_cast<FormFieldButton *>(Okular::PagePrivate::findEquivalentForm( newPagesVector[m_pageNumber], oldFormButton )); | 735 | FormFieldButton *button = dynamic_cast<FormFieldButton *>(Okular::PagePrivate::findEquivalentForm( newPagesVector[m_pageNumber], oldFormButton )); | ||
736 | if ( !button ) | 736 | if ( !button ) | ||
737 | return false; | 737 | return false; | ||
738 | m_formButtons << button; | 738 | m_formButtons << button; | ||
739 | } | 739 | } | ||
740 | 740 | | |||
741 | return true; | 741 | return true; | ||
742 | } | 742 | } | ||
743 | 743 | | |||
744 | void EditFormButtonsCommand::clearFormButtonStates() | 744 | void EditFormButtonsCommand::clearFormButtonStates() | ||
745 | { | 745 | { | ||
746 | foreach( FormFieldButton* formButton, m_formButtons ) | 746 | for ( FormFieldButton *formButton : qAsConst(m_formButtons) ) | ||
747 | { | 747 | { | ||
748 | formButton->setState( false ); | 748 | formButton->setState( false ); | ||
749 | } | 749 | } | ||
750 | } | 750 | } | ||
751 | 751 | | |||
752 | } | 752 | } | ||
753 | 753 | |