mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 19:50:27 +00:00
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:
parent
7f44aafa94
commit
fb825ff1d4
|
@ -15,6 +15,21 @@
|
||||||
// local includes
|
// local includes
|
||||||
#include "core/form.h"
|
#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 * FormWidgetFactory::createWidget( Okular::FormField * ff, QWidget * parent )
|
||||||
{
|
{
|
||||||
FormWidgetIface * widget = 0;
|
FormWidgetIface * widget = 0;
|
||||||
|
@ -58,7 +73,7 @@ FormWidgetIface * FormWidgetFactory::createWidget( Okular::FormField * ff, QWidg
|
||||||
|
|
||||||
|
|
||||||
FormWidgetIface::FormWidgetIface( QWidget * w, Okular::FormField * ff )
|
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 );
|
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 )
|
FormLineEdit::FormLineEdit( Okular::FormFieldText * text, QWidget * parent )
|
||||||
: QLineEdit( parent ), FormWidgetIface( this, text ), m_form( text )
|
: QLineEdit( parent ), FormWidgetIface( this, text ), m_form( text )
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <kurlrequester.h>
|
#include <kurlrequester.h>
|
||||||
|
|
||||||
class FormWidgetIface;
|
class FormWidgetIface;
|
||||||
|
class PageViewItem;
|
||||||
|
|
||||||
namespace Okular {
|
namespace Okular {
|
||||||
class FormField;
|
class FormField;
|
||||||
|
@ -27,6 +28,22 @@ class FormFieldChoice;
|
||||||
class FormFieldText;
|
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
|
class FormWidgetFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -46,9 +63,18 @@ class FormWidgetIface
|
||||||
bool setVisibility( bool visible );
|
bool setVisibility( bool visible );
|
||||||
void setCanBeFilled( bool fill );
|
void setCanBeFilled( bool fill );
|
||||||
|
|
||||||
|
void setPageItem( PageViewItem *pageItem );
|
||||||
|
PageViewItem* pageItem() const;
|
||||||
|
|
||||||
|
void setFormWidgetsController( FormWidgetsController *controller );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FormWidgetsController * m_controller;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget * m_widget;
|
QWidget * m_widget;
|
||||||
Okular::FormField * m_ff;
|
Okular::FormField * m_ff;
|
||||||
|
PageViewItem * m_pageItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,12 @@ static int pageflags = PagePainter::Accessibility | PagePainter::EnhanceLinks |
|
||||||
class PageViewPrivate
|
class PageViewPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
PageViewPrivate( PageView *qq );
|
||||||
|
|
||||||
|
FormWidgetsController* formWidgetsController();
|
||||||
|
|
||||||
// the document, pageviewItems and the 'visible cache'
|
// the document, pageviewItems and the 'visible cache'
|
||||||
|
PageView *q;
|
||||||
Okular::Document * document;
|
Okular::Document * document;
|
||||||
QVector< PageViewItem * > items;
|
QVector< PageViewItem * > items;
|
||||||
QLinkedList< PageViewItem * > visibleItems;
|
QLinkedList< PageViewItem * > visibleItems;
|
||||||
|
@ -121,6 +126,7 @@ public:
|
||||||
bool blockPixmapsRequest; // prevent pixmap requests
|
bool blockPixmapsRequest; // prevent pixmap requests
|
||||||
PageViewMessage * messageWindow; // in pageviewutils.h
|
PageViewMessage * messageWindow; // in pageviewutils.h
|
||||||
bool m_formsVisible;
|
bool m_formsVisible;
|
||||||
|
FormWidgetsController *formsWidgetController;
|
||||||
|
|
||||||
// drag scroll
|
// drag scroll
|
||||||
QPoint dragScrollVector;
|
QPoint dragScrollVector;
|
||||||
|
@ -151,6 +157,24 @@ public:
|
||||||
int setting_viewCols;
|
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
|
class PageViewWidget : public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -244,7 +268,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
|
||||||
: QScrollArea( parent )
|
: QScrollArea( parent )
|
||||||
{
|
{
|
||||||
// create and initialize private storage structure
|
// create and initialize private storage structure
|
||||||
d = new PageViewPrivate();
|
d = new PageViewPrivate( this );
|
||||||
d->document = document;
|
d->document = document;
|
||||||
d->aRotateClockwise = 0;
|
d->aRotateClockwise = 0;
|
||||||
d->aRotateCounterClockwise = 0;
|
d->aRotateCounterClockwise = 0;
|
||||||
|
@ -269,6 +293,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
|
||||||
d->blockPixmapsRequest = false;
|
d->blockPixmapsRequest = false;
|
||||||
d->messageWindow = new PageViewMessage(this);
|
d->messageWindow = new PageViewMessage(this);
|
||||||
d->m_formsVisible = false;
|
d->m_formsVisible = false;
|
||||||
|
d->formsWidgetController = 0;
|
||||||
d->aRotateClockwise = 0;
|
d->aRotateClockwise = 0;
|
||||||
d->aRotateCounterClockwise = 0;
|
d->aRotateCounterClockwise = 0;
|
||||||
d->aRotateOriginal = 0;
|
d->aRotateOriginal = 0;
|
||||||
|
@ -330,6 +355,7 @@ PageView::~PageView()
|
||||||
QVector< PageViewItem * >::const_iterator dIt = d->items.begin(), dEnd = d->items.end();
|
QVector< PageViewItem * >::const_iterator dIt = d->items.begin(), dEnd = d->items.end();
|
||||||
for ( ; dIt != dEnd; ++dIt )
|
for ( ; dIt != dEnd; ++dIt )
|
||||||
delete *dIt;
|
delete *dIt;
|
||||||
|
delete d->formsWidgetController;
|
||||||
d->document->removeObserver( this );
|
d->document->removeObserver( this );
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
@ -677,6 +703,8 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
|
||||||
FormWidgetIface * w = FormWidgetFactory::createWidget( ff, widget() );
|
FormWidgetIface * w = FormWidgetFactory::createWidget( ff, widget() );
|
||||||
if ( w )
|
if ( w )
|
||||||
{
|
{
|
||||||
|
w->setPageItem( item );
|
||||||
|
w->setFormWidgetsController( d->formWidgetsController() );
|
||||||
w->setVisibility( d->m_formsVisible );
|
w->setVisibility( d->m_formsVisible );
|
||||||
w->setCanBeFilled( d->document->isAllowed( Okular::AllowFillForms ) );
|
w->setCanBeFilled( d->document->isAllowed( Okular::AllowFillForms ) );
|
||||||
item->formWidgets().insert( ff->name(), w );
|
item->formWidgets().insert( ff->name(), w );
|
||||||
|
@ -3153,6 +3181,10 @@ void PageView::slotToggleForms()
|
||||||
{
|
{
|
||||||
toggleFormWidgets( !d->m_formsVisible );
|
toggleFormWidgets( !d->m_formsVisible );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PageView::slotFormWidgetChanged( FormWidgetIface *w )
|
||||||
|
{
|
||||||
|
}
|
||||||
//END private SLOTS
|
//END private SLOTS
|
||||||
|
|
||||||
#include "pageview.moc"
|
#include "pageview.moc"
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Document;
|
||||||
class Annotation;
|
class Annotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FormWidgetIface;
|
||||||
class PageViewPrivate;
|
class PageViewPrivate;
|
||||||
class PageViewWidget;
|
class PageViewWidget;
|
||||||
|
|
||||||
|
@ -194,6 +195,7 @@ Q_OBJECT
|
||||||
void slotRotateOriginal();
|
void slotRotateOriginal();
|
||||||
void slotPageSizes( int );
|
void slotPageSizes( int );
|
||||||
void slotToggleForms();
|
void slotToggleForms();
|
||||||
|
void slotFormWidgetChanged( FormWidgetIface *w );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue