Commit 53a8acf8 authored by Joao Oliveira's avatar Joao Oliveira Committed by Albert Astals Cid

Removed the use of internalText(), replacing by text()

parent b66df684
......@@ -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 )
......
......@@ -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 );
}
......
......@@ -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:
......
......@@ -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.
*
......
......@@ -171,7 +171,7 @@ std::shared_ptr<Event> 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> Event::createFormatEvent( FormField *target,
FormFieldText *fft = dynamic_cast< FormFieldText * >(target);
if ( fft )
{
ret->setValue( QVariant( fft->internalText() ) );
ret->setValue( QVariant( fft->text() ) );
}
return ret;
}
......
......@@ -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;
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment