Commit 604187b7 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Ui work for Reset Form Action support

Heavily inspired in Guillermo Amaral patches
CCMAIL: gamaral@kde.org
parent 258cd656
......@@ -366,6 +366,7 @@ m_cliPresentation(false), m_embedMode(detectEmbedMode(parentWidget, parent, args
connect( m_document, SIGNAL(error(QString,int)), m_pageView, SLOT(errorMessage(QString,int)) );
connect( m_document, SIGNAL(warning(QString,int)), m_pageView, SLOT(warningMessage(QString,int)) );
connect( m_document, SIGNAL(notice(QString,int)), m_pageView, SLOT(noticeMessage(QString,int)) );
connect( m_document, SIGNAL(formFieldChanged(Okular::FormField*)), m_pageView, SLOT(slotFormFieldChanged(Okular::FormField*)) );
rightLayout->addWidget( m_pageView );
m_findBar = new FindBar( m_document, rightContainer );
rightLayout->addWidget( m_findBar );
......
......@@ -3708,6 +3708,40 @@ void PageView::slotAction( Okular::Action *action )
d->document->processAction( action );
}
void PageView::slotFormFieldChanged( Okular::FormField *ff )
{
QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd();
for ( ; dIt != dEnd; ++dIt )
{
FormWidgetIface *fw = (*dIt)->formWidgets().value( ff->id() );
if (fw != NULL)
{
switch (ff->type()) {
case Okular::FormField::FormText: {
Okular::FormFieldText* fft = static_cast<Okular::FormFieldText *>(ff);
FormLineEdit *le = dynamic_cast<FormLineEdit *>(fw);
TextAreaEdit *te = dynamic_cast<TextAreaEdit *>(fw);
if (le) le->setText( fft->text() );
if (te) te->setText( fft->text() );
} break;
case Okular::FormField::FormButton: {
Okular::FormFieldButton* ffb = static_cast<Okular::FormFieldButton *>(ff);
QAbstractButton *be = dynamic_cast<QAbstractButton *>(fw);
if (be) be->setChecked( ffb->state() );
} break;
default:
kDebug() << "Unhandled form field: " << ff->name() << ff->defaultValue();
break;
}
break; // Found the widget, no need to loop more pages
}
}
}
void PageView::externalKeyPressEvent( QKeyEvent *e )
{
keyPressEvent( e );
......
......@@ -36,6 +36,7 @@ namespace Okular {
class Action;
class Document;
class Annotation;
class FormField;
}
class FormWidgetIface;
......@@ -229,6 +230,7 @@ Q_OBJECT
void slotSpeakCurrentPage();
void slotStopSpeaks();
void slotAction( Okular::Action *action );
void slotFormFieldChanged( Okular::FormField *formField );
void externalKeyPressEvent( QKeyEvent *e );
};
......
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