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

remotes/origin/more-conventional-sidebar
João Netto 7 years ago committed by Albert Astals Cid
parent b66df68452
commit 53a8acf813
  1. 12
      core/document.cpp
  2. 2
      core/documentcommands.cpp
  3. 31
      core/form.cpp
  4. 25
      core/form.h
  5. 4
      core/script/event.cpp
  6. 5
      core/script/kjs_field.cpp
  7. 4
      ui/formwidgets.cpp

@ -4328,9 +4328,6 @@ void Document::processFormatAction( const Action * action, Okular::FormFieldText
const QString oldVal = fft->text(); 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] ); std::shared_ptr< Event > event = Event::createFormatEvent( fft, d->m_pagesVector[foundPage] );
const ScriptAction * linkscript = static_cast< const ScriptAction * >( action ); 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(); const QString newVal = event->value().toString();
if ( newVal != oldVal ) if ( newVal != oldVal )
{ {
// We set the newVal, because when we call refreshFormWidget
// It will set the QLineEdit to this newVal
fft->setText( newVal ); fft->setText( newVal );
emit refreshFormWidget( fft ); emit refreshFormWidget( fft );
d->refreshPixmaps( foundPage ); 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 ) ) else if ( fft->additionalAction( FormField::CalculateField ) )
{ {
@ -4400,10 +4402,6 @@ void Document::processKeystrokeAction( const Action * action, Okular::FormFieldT
// Clear out the event after execution // Clear out the event after execution
d->m_scripter->setEvent( nullptr ); d->m_scripter->setEvent( nullptr );
returnCode = event->returnCode(); returnCode = event->returnCode();
if( returnCode )
{
fft->setInternalText( fft->text() );
}
} }
void Document::processSourceReference( const SourceReference * ref ) void Document::processSourceReference( const SourceReference * ref )

@ -506,7 +506,6 @@ void EditFormTextCommand::undo()
{ {
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber ); moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
m_form->setText( m_prevContents ); 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 ); emit m_docPriv->m_parent->formTextChangedByUndoRedo( m_pageNumber, m_form, m_prevContents, m_prevCursorPos, m_prevAnchorPos );
m_docPriv->notifyFormChanges( m_pageNumber ); m_docPriv->notifyFormChanges( m_pageNumber );
} }
@ -515,7 +514,6 @@ void EditFormTextCommand::redo()
{ {
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber ); moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
m_form->setText( m_newContents ); 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 ); emit m_docPriv->m_parent->formTextChangedByUndoRedo( m_pageNumber, m_form, m_newContents, m_newCursorPos, m_newCursorPos );
m_docPriv->notifyFormChanges( m_pageNumber ); m_docPriv->notifyFormChanges( m_pageNumber );
} }

@ -182,19 +182,6 @@ class Okular::FormFieldTextPrivate : public Okular::FormFieldPrivate
Q_Q( const FormFieldText ); Q_Q( const FormFieldText );
return q->text(); 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; 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 class Okular::FormFieldChoicePrivate : public Okular::FormFieldPrivate
{ {
public: public:

@ -317,31 +317,6 @@ class OKULARCORE_EXPORT FormFieldText : public FormField
*/ */
virtual bool canBeSpellChecked() const; 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. * 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); FormFieldText *fft = dynamic_cast< FormFieldText * >(target);
if ( fft ) if ( fft )
{ {
ret->setValue( QVariant( fft->internalText() ) ); ret->setValue( QVariant( fft->text() ) );
} }
return ret; return ret;
} }
@ -189,7 +189,7 @@ std::shared_ptr<Event> Event::createFormatEvent( FormField *target,
FormFieldText *fft = dynamic_cast< FormFieldText * >(target); FormFieldText *fft = dynamic_cast< FormFieldText * >(target);
if ( fft ) if ( fft )
{ {
ret->setValue( QVariant( fft->internalText() ) ); ret->setValue( QVariant( fft->text() ) );
} }
return ret; return ret;
} }

@ -148,7 +148,7 @@ static KJSObject fieldGetValue( KJSContext */*context*/, void *object )
case FormField::FormText: case FormField::FormText:
{ {
const FormFieldText *text = static_cast< const FormFieldText * >( field ); const FormFieldText *text = static_cast< const FormFieldText * >( field );
return KJSString( text->internalText() ); return KJSString( text->text() );
} }
case FormField::FormChoice: case FormField::FormChoice:
{ {
@ -192,10 +192,9 @@ static void fieldSetValue( KJSContext *context, void *object, KJSObject value )
{ {
FormFieldText *textField = static_cast< FormFieldText * >( field ); FormFieldText *textField = static_cast< FormFieldText * >( field );
const QString text = value.toString( context ); const QString text = value.toString( context );
if ( text != textField->internalText() ) if ( text != textField->text() )
{ {
textField->setText( text ); textField->setText( text );
textField->setInternalText( text );
updateField( field ); updateField( field );
} }
break; break;

@ -505,7 +505,7 @@ bool FormLineEdit::event( QEvent* e )
else if ( e->type() == QEvent::FocusIn ) else if ( e->type() == QEvent::FocusIn )
{ {
const auto fft = static_cast< Okular::FormFieldText * > ( m_ff ); const auto fft = static_cast< Okular::FormFieldText * > ( m_ff );
setText( fft->internalText() ); setText( fft->text() );
m_editing = true; m_editing = true;
} }
else if ( e->type() == QEvent::FocusOut ) else if ( e->type() == QEvent::FocusOut )
@ -667,7 +667,7 @@ bool TextAreaEdit::event( QEvent* e )
else if ( e->type() == QEvent::FocusIn ) else if ( e->type() == QEvent::FocusIn )
{ {
const auto fft = static_cast< Okular::FormFieldText * > ( m_ff ); const auto fft = static_cast< Okular::FormFieldText * > ( m_ff );
setText( fft->internalText() ); setText( fft->text() );
m_editing = true; m_editing = true;
} }
else if ( e->type() == QEvent::FocusOut ) else if ( e->type() == QEvent::FocusOut )

Loading…
Cancel
Save