add a form widget controller to prepare the pageview to possible changes when the content in a form widget changes

svn path=/trunk/KDE/kdegraphics/okular/; revision=726788
This commit is contained in:
Pino Toscano 2007-10-18 22:09:49 +00:00
parent 7f44aafa94
commit fb825ff1d4
4 changed files with 92 additions and 2 deletions

View file

@ -15,6 +15,21 @@
// local includes
#include "core/form.h"
FormWidgetsController::FormWidgetsController( QObject *parent )
: QObject( parent )
{
}
FormWidgetsController::~FormWidgetsController()
{
}
void FormWidgetsController::signalChanged( FormWidgetIface *w )
{
emit changed( w );
}
FormWidgetIface * FormWidgetFactory::createWidget( Okular::FormField * ff, QWidget * parent )
{
FormWidgetIface * widget = 0;
@ -58,7 +73,7 @@ FormWidgetIface * FormWidgetFactory::createWidget( Okular::FormField * ff, QWidg
FormWidgetIface::FormWidgetIface( QWidget * w, Okular::FormField * ff )
: m_widget( w ), m_ff( ff )
: m_controller( 0 ), m_widget( w ), m_ff( ff ), m_pageItem( 0 )
{
}
@ -98,6 +113,21 @@ void FormWidgetIface::setCanBeFilled( bool fill )
m_widget->setEnabled( fill );
}
void FormWidgetIface::setPageItem( PageViewItem *pageItem )
{
m_pageItem = pageItem;
}
PageViewItem* FormWidgetIface::pageItem() const
{
return m_pageItem;
}
void FormWidgetIface::setFormWidgetsController( FormWidgetsController *controller )
{
m_controller = controller;
}
FormLineEdit::FormLineEdit( Okular::FormFieldText * text, QWidget * parent )
: QLineEdit( parent ), FormWidgetIface( this, text ), m_form( text )

View file

@ -20,6 +20,7 @@
#include <kurlrequester.h>
class FormWidgetIface;
class PageViewItem;
namespace Okular {
class FormField;
@ -27,6 +28,22 @@ class FormFieldChoice;
class FormFieldText;
}
class FormWidgetsController : public QObject
{
Q_OBJECT
public:
FormWidgetsController( QObject *parent = 0 );
virtual ~FormWidgetsController();
void signalChanged( FormWidgetIface *w );
signals:
void changed( FormWidgetIface *w );
};
class FormWidgetFactory
{
public:
@ -46,9 +63,18 @@ class FormWidgetIface
bool setVisibility( bool visible );
void setCanBeFilled( bool fill );
void setPageItem( PageViewItem *pageItem );
PageViewItem* pageItem() const;
void setFormWidgetsController( FormWidgetsController *controller );
protected:
FormWidgetsController * m_controller;
private:
QWidget * m_widget;
Okular::FormField * m_ff;
PageViewItem * m_pageItem;
};

View file

@ -79,7 +79,12 @@ static int pageflags = PagePainter::Accessibility | PagePainter::EnhanceLinks |
class PageViewPrivate
{
public:
PageViewPrivate( PageView *qq );
FormWidgetsController* formWidgetsController();
// the document, pageviewItems and the 'visible cache'
PageView *q;
Okular::Document * document;
QVector< PageViewItem * > items;
QLinkedList< PageViewItem * > visibleItems;
@ -121,6 +126,7 @@ public:
bool blockPixmapsRequest; // prevent pixmap requests
PageViewMessage * messageWindow; // in pageviewutils.h
bool m_formsVisible;
FormWidgetsController *formsWidgetController;
// drag scroll
QPoint dragScrollVector;
@ -151,6 +157,24 @@ public:
int setting_viewCols;
};
PageViewPrivate::PageViewPrivate( PageView *qq )
: q( qq )
{
}
FormWidgetsController* PageViewPrivate::formWidgetsController()
{
if ( !formsWidgetController )
{
formsWidgetController = new FormWidgetsController();
QObject::connect( formsWidgetController, SIGNAL( changed( FormWidgetIface* ) ),
q, SLOT( slotFormWidgetChanged( FormWidgetIface * ) ) );
}
return formsWidgetController;
}
class PageViewWidget : public QWidget
{
public:
@ -244,7 +268,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
: QScrollArea( parent )
{
// create and initialize private storage structure
d = new PageViewPrivate();
d = new PageViewPrivate( this );
d->document = document;
d->aRotateClockwise = 0;
d->aRotateCounterClockwise = 0;
@ -269,6 +293,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->blockPixmapsRequest = false;
d->messageWindow = new PageViewMessage(this);
d->m_formsVisible = false;
d->formsWidgetController = 0;
d->aRotateClockwise = 0;
d->aRotateCounterClockwise = 0;
d->aRotateOriginal = 0;
@ -330,6 +355,7 @@ PageView::~PageView()
QVector< PageViewItem * >::const_iterator dIt = d->items.begin(), dEnd = d->items.end();
for ( ; dIt != dEnd; ++dIt )
delete *dIt;
delete d->formsWidgetController;
d->document->removeObserver( this );
delete d;
}
@ -677,6 +703,8 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
FormWidgetIface * w = FormWidgetFactory::createWidget( ff, widget() );
if ( w )
{
w->setPageItem( item );
w->setFormWidgetsController( d->formWidgetsController() );
w->setVisibility( d->m_formsVisible );
w->setCanBeFilled( d->document->isAllowed( Okular::AllowFillForms ) );
item->formWidgets().insert( ff->name(), w );
@ -3153,6 +3181,10 @@ void PageView::slotToggleForms()
{
toggleFormWidgets( !d->m_formsVisible );
}
void PageView::slotFormWidgetChanged( FormWidgetIface *w )
{
}
//END private SLOTS
#include "pageview.moc"

View file

@ -35,6 +35,7 @@ class Document;
class Annotation;
}
class FormWidgetIface;
class PageViewPrivate;
class PageViewWidget;
@ -194,6 +195,7 @@ Q_OBJECT
void slotRotateOriginal();
void slotPageSizes( int );
void slotToggleForms();
void slotFormWidgetChanged( FormWidgetIface *w );
};
#endif