Changeset View
Changeset View
Standalone View
Standalone View
ui/formwidgets.cpp
Show First 20 Lines • Show All 327 Lines • ▼ Show 20 Line(s) | |||||
328 | PageViewItem* FormWidgetIface::pageItem() const | 328 | PageViewItem* FormWidgetIface::pageItem() const | ||
329 | { | 329 | { | ||
330 | return m_pageItem; | 330 | return m_pageItem; | ||
331 | } | 331 | } | ||
332 | 332 | | |||
333 | void FormWidgetIface::setFormWidgetsController( FormWidgetsController *controller ) | 333 | void FormWidgetIface::setFormWidgetsController( FormWidgetsController *controller ) | ||
334 | { | 334 | { | ||
335 | m_controller = controller; | 335 | m_controller = controller; | ||
336 | QObject *obj = dynamic_cast< QObject * > ( this ); | ||||
337 | QObject::connect( m_controller, &FormWidgetsController::refreshFormWidget, obj, | ||||
338 | [this] ( Okular::FormField *form ) { | ||||
339 | slotRefresh ( form ); | ||||
340 | }); | ||||
341 | } | ||||
342 | | ||||
343 | void FormWidgetIface::slotRefresh( Okular::FormField * form ) | ||||
344 | { | ||||
345 | if ( m_ff != form ) | ||||
346 | { | ||||
347 | return; | ||||
348 | } | ||||
349 | setVisibility( form->isVisible() && !form->isReadOnly() ); | ||||
350 | | ||||
351 | m_widget->setEnabled( !form->isReadOnly() ); | ||||
336 | } | 352 | } | ||
337 | 353 | | |||
338 | 354 | | |||
339 | PushButtonEdit::PushButtonEdit( Okular::FormFieldButton * button, QWidget * parent ) | 355 | PushButtonEdit::PushButtonEdit( Okular::FormFieldButton * button, QWidget * parent ) | ||
340 | : QPushButton( parent ), FormWidgetIface( this, button ) | 356 | : QPushButton( parent ), FormWidgetIface( this, button ) | ||
341 | { | 357 | { | ||
342 | setText( button->caption() ); | 358 | setText( button->caption() ); | ||
343 | setVisible( button->isVisible() ); | 359 | setVisible( button->isVisible() ); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 418 | { | |||
417 | setVisible( text->isVisible() ); | 433 | setVisible( text->isVisible() ); | ||
418 | } | 434 | } | ||
419 | 435 | | |||
420 | void FormLineEdit::setFormWidgetsController(FormWidgetsController* controller) | 436 | void FormLineEdit::setFormWidgetsController(FormWidgetsController* controller) | ||
421 | { | 437 | { | ||
422 | FormWidgetIface::setFormWidgetsController(controller); | 438 | FormWidgetIface::setFormWidgetsController(controller); | ||
423 | connect( m_controller, &FormWidgetsController::formTextChangedByUndoRedo, | 439 | connect( m_controller, &FormWidgetsController::formTextChangedByUndoRedo, | ||
424 | this, &FormLineEdit::slotHandleTextChangedByUndoRedo ); | 440 | this, &FormLineEdit::slotHandleTextChangedByUndoRedo ); | ||
425 | connect( m_controller, &FormWidgetsController::refreshFormWidget, | | |||
426 | this, &FormLineEdit::slotRefresh ); | | |||
427 | } | 441 | } | ||
428 | 442 | | |||
429 | bool FormLineEdit::event( QEvent* e ) | 443 | bool FormLineEdit::event( QEvent* e ) | ||
430 | { | 444 | { | ||
431 | if ( e->type() == QEvent::KeyPress ) | 445 | if ( e->type() == QEvent::KeyPress ) | ||
432 | { | 446 | { | ||
433 | QKeyEvent *keyEvent = static_cast< QKeyEvent* >( e ); | 447 | QKeyEvent *keyEvent = static_cast< QKeyEvent* >( e ); | ||
434 | if ( keyEvent == QKeySequence::Undo ) | 448 | if ( keyEvent == QKeySequence::Undo ) | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | |||||
521 | } | 535 | } | ||
522 | 536 | | |||
523 | void FormLineEdit::slotRefresh( Okular::FormField *form ) | 537 | void FormLineEdit::slotRefresh( Okular::FormField *form ) | ||
524 | { | 538 | { | ||
525 | if (form != m_ff) | 539 | if (form != m_ff) | ||
526 | { | 540 | { | ||
527 | return; | 541 | return; | ||
528 | } | 542 | } | ||
529 | Okular::FormFieldText *text = static_cast<Okular::FormFieldText *> ( form ); | 543 | FormWidgetIface::slotRefresh( form ); | ||
530 | 544 | | |||
545 | Okular::FormFieldText *text = static_cast<Okular::FormFieldText *> ( form ); | ||||
531 | setText( text->text() ); | 546 | setText( text->text() ); | ||
532 | } | 547 | } | ||
533 | 548 | | |||
534 | TextAreaEdit::TextAreaEdit( Okular::FormFieldText * text, QWidget * parent ) | 549 | TextAreaEdit::TextAreaEdit( Okular::FormFieldText * text, QWidget * parent ) | ||
535 | : KTextEdit( parent ), FormWidgetIface( this, text ) | 550 | : KTextEdit( parent ), FormWidgetIface( this, text ) | ||
536 | { | 551 | { | ||
537 | setAcceptRichText( text->isRichText() ); | 552 | setAcceptRichText( text->isRichText() ); | ||
538 | setCheckSpellingEnabled( text->canBeSpellChecked() ); | 553 | setCheckSpellingEnabled( text->canBeSpellChecked() ); | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 587 | { | |||
593 | menu->removeAction( oldRedo ); | 608 | menu->removeAction( oldRedo ); | ||
594 | } | 609 | } | ||
595 | 610 | | |||
596 | void TextAreaEdit::setFormWidgetsController( FormWidgetsController* controller ) | 611 | void TextAreaEdit::setFormWidgetsController( FormWidgetsController* controller ) | ||
597 | { | 612 | { | ||
598 | FormWidgetIface::setFormWidgetsController( controller ); | 613 | FormWidgetIface::setFormWidgetsController( controller ); | ||
599 | connect( m_controller, &FormWidgetsController::formTextChangedByUndoRedo, | 614 | connect( m_controller, &FormWidgetsController::formTextChangedByUndoRedo, | ||
600 | this, &TextAreaEdit::slotHandleTextChangedByUndoRedo ); | 615 | this, &TextAreaEdit::slotHandleTextChangedByUndoRedo ); | ||
601 | connect( m_controller, &FormWidgetsController::refreshFormWidget, | | |||
602 | this, &TextAreaEdit::slotRefresh ); | | |||
603 | } | 616 | } | ||
604 | 617 | | |||
605 | void TextAreaEdit::slotHandleTextChangedByUndoRedo( int pageNumber, | 618 | void TextAreaEdit::slotHandleTextChangedByUndoRedo( int pageNumber, | ||
606 | Okular::FormFieldText* textForm, | 619 | Okular::FormFieldText* textForm, | ||
607 | const QString & contents, | 620 | const QString & contents, | ||
608 | int cursorPos, | 621 | int cursorPos, | ||
609 | int anchorPos ) | 622 | int anchorPos ) | ||
610 | { | 623 | { | ||
Show All 31 Lines | |||||
642 | } | 655 | } | ||
643 | 656 | | |||
644 | void TextAreaEdit::slotRefresh( Okular::FormField *form ) | 657 | void TextAreaEdit::slotRefresh( Okular::FormField *form ) | ||
645 | { | 658 | { | ||
646 | if (form != m_ff) | 659 | if (form != m_ff) | ||
647 | { | 660 | { | ||
648 | return; | 661 | return; | ||
649 | } | 662 | } | ||
650 | Okular::FormFieldText *text = static_cast<Okular::FormFieldText *> ( form ); | 663 | FormWidgetIface::slotRefresh( form ); | ||
651 | 664 | | |||
665 | Okular::FormFieldText *text = static_cast<Okular::FormFieldText *> ( form ); | ||||
652 | setPlainText( text->text() ); | 666 | setPlainText( text->text() ); | ||
653 | } | 667 | } | ||
654 | 668 | | |||
655 | FileEdit::FileEdit( Okular::FormFieldText * text, QWidget * parent ) | 669 | FileEdit::FileEdit( Okular::FormFieldText * text, QWidget * parent ) | ||
656 | : KUrlRequester( parent ), FormWidgetIface( this, text ) | 670 | : KUrlRequester( parent ), FormWidgetIface( this, text ) | ||
657 | { | 671 | { | ||
658 | setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ); | 672 | setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ); | ||
659 | setFilter( i18n( "*|All Files" ) ); | 673 | setFilter( i18n( "*|All Files" ) ); | ||
▲ Show 20 Lines • Show All 351 Lines • Show Last 20 Lines |