Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 5c04f083 authored by Andre Heinecke's avatar Andre Heinecke Committed by Albert Astals Cid

Implement generic version of Form Widgets refresh

Summary:
The FormWidgetInterface now has a generic slotRefresh that
refreshes what all widgets have in common. This is the read-only state for now.

Reviewers: #okular

Tags: #okular

Maniphest Tasks: T8097

Differential Revision: https://phabricator.kde.org/D10866
parent 42717e1a
......@@ -333,6 +333,22 @@ PageViewItem* FormWidgetIface::pageItem() const
void FormWidgetIface::setFormWidgetsController( FormWidgetsController *controller )
{
m_controller = controller;
QObject *obj = dynamic_cast< QObject * > ( this );
QObject::connect( m_controller, &FormWidgetsController::refreshFormWidget, obj,
[this] ( Okular::FormField *form ) {
slotRefresh ( form );
});
}
void FormWidgetIface::slotRefresh( Okular::FormField * form )
{
if ( m_ff != form )
{
return;
}
setVisibility( form->isVisible() && !form->isReadOnly() );
m_widget->setEnabled( !form->isReadOnly() );
}
......@@ -422,8 +438,6 @@ void FormLineEdit::setFormWidgetsController(FormWidgetsController* controller)
FormWidgetIface::setFormWidgetsController(controller);
connect( m_controller, &FormWidgetsController::formTextChangedByUndoRedo,
this, &FormLineEdit::slotHandleTextChangedByUndoRedo );
connect( m_controller, &FormWidgetsController::refreshFormWidget,
this, &FormLineEdit::slotRefresh );
}
bool FormLineEdit::event( QEvent* e )
......@@ -526,8 +540,9 @@ void FormLineEdit::slotRefresh( Okular::FormField *form )
{
return;
}
Okular::FormFieldText *text = static_cast<Okular::FormFieldText *> ( form );
FormWidgetIface::slotRefresh( form );
Okular::FormFieldText *text = static_cast<Okular::FormFieldText *> ( form );
setText( text->text() );
}
......@@ -598,8 +613,6 @@ void TextAreaEdit::setFormWidgetsController( FormWidgetsController* controller )
FormWidgetIface::setFormWidgetsController( controller );
connect( m_controller, &FormWidgetsController::formTextChangedByUndoRedo,
this, &TextAreaEdit::slotHandleTextChangedByUndoRedo );
connect( m_controller, &FormWidgetsController::refreshFormWidget,
this, &TextAreaEdit::slotRefresh );
}
void TextAreaEdit::slotHandleTextChangedByUndoRedo( int pageNumber,
......@@ -647,8 +660,9 @@ void TextAreaEdit::slotRefresh( Okular::FormField *form )
{
return;
}
Okular::FormFieldText *text = static_cast<Okular::FormFieldText *> ( form );
FormWidgetIface::slotRefresh( form );
Okular::FormFieldText *text = static_cast<Okular::FormFieldText *> ( form );
setPlainText( text->text() );
}
......
......@@ -160,6 +160,8 @@ class FormWidgetIface
virtual void setFormWidgetsController( FormWidgetsController *controller );
protected:
virtual void slotRefresh( Okular::FormField *form );
FormWidgetsController * m_controller;
Okular::FormField * m_ff;
......@@ -224,7 +226,9 @@ class FormLineEdit : public QLineEdit, public FormWidgetIface
int anchorPos );
private Q_SLOTS:
void slotChanged();
void slotRefresh(Okular::FormField* form);
protected:
void slotRefresh( Okular::FormField* form ) override;
private:
int m_prevCursorPos;
......@@ -251,7 +255,9 @@ class TextAreaEdit : public KTextEdit, public FormWidgetIface
private Q_SLOTS:
void slotChanged();
void slotRefresh(Okular::FormField* form);
protected:
void slotRefresh( Okular::FormField* form ) override;
private:
int m_prevCursorPos;
......
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