diff --git a/core/document.cpp b/core/document.cpp index e5c28861c..f70fa3522 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -4328,9 +4328,6 @@ void Document::processFormatAction( const Action * action, Okular::FormFieldText const QString oldVal = fft->text(); - // We are before formatting. So the unformatted text is currently in fft->text() - // Internally we want to use the current value for calculations and formatting. - fft->setInternalText( oldVal ); std::shared_ptr< Event > event = Event::createFormatEvent( fft, d->m_pagesVector[foundPage] ); const ScriptAction * linkscript = static_cast< const ScriptAction * >( action ); @@ -4347,9 +4344,14 @@ void Document::processFormatAction( const Action * action, Okular::FormFieldText const QString newVal = event->value().toString(); if ( newVal != oldVal ) { + // We set the newVal, because when we call refreshFormWidget + // It will set the QLineEdit to this newVal fft->setText( newVal ); emit refreshFormWidget( fft ); d->refreshPixmaps( foundPage ); + // Then we make the form have the unformatted text, to use + // in calculations and other things. + fft->setText( oldVal ); } else if ( fft->additionalAction( FormField::CalculateField ) ) { @@ -4400,10 +4402,6 @@ void Document::processKeystrokeAction( const Action * action, Okular::FormFieldT // Clear out the event after execution d->m_scripter->setEvent( nullptr ); returnCode = event->returnCode(); - if( returnCode ) - { - fft->setInternalText( fft->text() ); - } } void Document::processSourceReference( const SourceReference * ref ) diff --git a/core/documentcommands.cpp b/core/documentcommands.cpp index c30391b07..e3ec520aa 100644 --- a/core/documentcommands.cpp +++ b/core/documentcommands.cpp @@ -506,7 +506,6 @@ void EditFormTextCommand::undo() { moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber ); m_form->setText( m_prevContents ); - m_form->setInternalText( m_prevContents ); emit m_docPriv->m_parent->formTextChangedByUndoRedo( m_pageNumber, m_form, m_prevContents, m_prevCursorPos, m_prevAnchorPos ); m_docPriv->notifyFormChanges( m_pageNumber ); } @@ -515,7 +514,6 @@ void EditFormTextCommand::redo() { moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber ); m_form->setText( m_newContents ); - m_form->setInternalText( m_newContents ); emit m_docPriv->m_parent->formTextChangedByUndoRedo( m_pageNumber, m_form, m_newContents, m_newCursorPos, m_newCursorPos ); m_docPriv->notifyFormChanges( m_pageNumber ); } diff --git a/core/form.cpp b/core/form.cpp index a4e14dcf0..a7107929b 100644 --- a/core/form.cpp +++ b/core/form.cpp @@ -182,19 +182,6 @@ class Okular::FormFieldTextPrivate : public Okular::FormFieldPrivate Q_Q( const FormFieldText ); return q->text(); } - - void setInternalText( const QString& v ) - { - m_internalText = v; - } - - QString internalText() const - { - return m_internalText; - } - - private: - QString m_internalText; }; @@ -236,24 +223,6 @@ bool FormFieldText::canBeSpellChecked() const return false; } -QString FormFieldText::internalText() const -{ - Q_D( const FormFieldText ); - const QString val = d->internalText(); - if ( val.isNull() ) - { - return text(); - } - return val; -} - -void FormFieldText::setInternalText( const QString &text ) -{ - Q_D( FormFieldText ); - d->setInternalText( text ); -} - - class Okular::FormFieldChoicePrivate : public Okular::FormFieldPrivate { public: diff --git a/core/form.h b/core/form.h index f29b8c49b..e7efcb87c 100644 --- a/core/form.h +++ b/core/form.h @@ -317,31 +317,6 @@ class OKULARCORE_EXPORT FormFieldText : public FormField */ virtual bool canBeSpellChecked() const; - /** - * Optionally different internal text. - * - * Internal text is the value of the field before formatting - * and should be used for editing and calculations. - * - * The default implementation returns the value of - * @ref text if no internal text was set. - * - * @since 1.5 - */ - virtual QString internalText() const; - - /** - * Set internalText to a value before formatting. - * - * If the text value was changed for display purposes use - * setRawText to store the internal value @p text before - * formatting. The internal text is used for calculations - * and editing. - * - * @since 1.5 - */ - virtual void setInternalText( const QString &text ); - /** * Set the text which should be rendered by the PDF. * diff --git a/core/script/event.cpp b/core/script/event.cpp index dfe79b454..4bc8acd6f 100644 --- a/core/script/event.cpp +++ b/core/script/event.cpp @@ -171,7 +171,7 @@ std::shared_ptr Event::createFormCalculateEvent( FormField *target, FormFieldText *fft = dynamic_cast< FormFieldText * >(target); if ( fft ) { - ret->setValue( QVariant( fft->internalText() ) ); + ret->setValue( QVariant( fft->text() ) ); } return ret; } @@ -189,7 +189,7 @@ std::shared_ptr Event::createFormatEvent( FormField *target, FormFieldText *fft = dynamic_cast< FormFieldText * >(target); if ( fft ) { - ret->setValue( QVariant( fft->internalText() ) ); + ret->setValue( QVariant( fft->text() ) ); } return ret; } diff --git a/core/script/kjs_field.cpp b/core/script/kjs_field.cpp index afd3bacc9..ff96ba015 100644 --- a/core/script/kjs_field.cpp +++ b/core/script/kjs_field.cpp @@ -148,7 +148,7 @@ static KJSObject fieldGetValue( KJSContext */*context*/, void *object ) case FormField::FormText: { const FormFieldText *text = static_cast< const FormFieldText * >( field ); - return KJSString( text->internalText() ); + return KJSString( text->text() ); } case FormField::FormChoice: { @@ -192,10 +192,9 @@ static void fieldSetValue( KJSContext *context, void *object, KJSObject value ) { FormFieldText *textField = static_cast< FormFieldText * >( field ); const QString text = value.toString( context ); - if ( text != textField->internalText() ) + if ( text != textField->text() ) { textField->setText( text ); - textField->setInternalText( text ); updateField( field ); } break; diff --git a/ui/formwidgets.cpp b/ui/formwidgets.cpp index 8d833ae5c..36abf6ab8 100644 --- a/ui/formwidgets.cpp +++ b/ui/formwidgets.cpp @@ -505,7 +505,7 @@ bool FormLineEdit::event( QEvent* e ) else if ( e->type() == QEvent::FocusIn ) { const auto fft = static_cast< Okular::FormFieldText * > ( m_ff ); - setText( fft->internalText() ); + setText( fft->text() ); m_editing = true; } else if ( e->type() == QEvent::FocusOut ) @@ -667,7 +667,7 @@ bool TextAreaEdit::event( QEvent* e ) else if ( e->type() == QEvent::FocusIn ) { const auto fft = static_cast< Okular::FormFieldText * > ( m_ff ); - setText( fft->internalText() ); + setText( fft->text() ); m_editing = true; } else if ( e->type() == QEvent::FocusOut )