Ui work for Reset Form Action support

Heavily inspired in Guillermo Amaral patches
CCMAIL: gamaral@kde.org
This commit is contained in:
Albert Astals Cid 2011-08-25 02:25:43 +02:00
parent 258cd6562a
commit 604187b7a3
3 changed files with 37 additions and 0 deletions

View file

@ -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 );

View file

@ -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 );

View file

@ -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 );
};