1 /***************************************************************************
2 * Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _OKULAR_FORMWIDGETS_H_
11 #define _OKULAR_FORMWIDGETS_H_
13 #include "core/area.h"
15 #include <qcheckbox.h>
16 #include <qcombobox.h>
17 #include <qlineedit.h>
18 #include <qlistwidget.h>
19 #include <qpushbutton.h>
20 #include <qradiobutton.h>
21 #include <ktextedit.h>
22 #include <kurlrequester.h>
25 class FormWidgetIface
;
27 class RadioButtonEdit
;
32 class FormFieldButton
;
33 class FormFieldChoice
;
45 class FormWidgetsController
: public QObject
50 FormWidgetsController( QObject
*parent
= 0 );
51 virtual ~FormWidgetsController();
53 void signalChanged( FormWidgetIface
*w
);
54 void signalAction( Okular::Action
*action
);
56 QButtonGroup
* registerRadioButton( FormWidgetIface
* widget
, const QList
< int >& siblings
);
57 void dropRadioButtons();
60 void changed( FormWidgetIface
*w
);
61 void action( Okular::Action
*action
);
64 void slotButtonClicked( QAbstractButton
*button
);
67 QList
< RadioData
> m_radios
;
71 class FormWidgetFactory
74 static FormWidgetIface
* createWidget( Okular::FormField
* ff
, QWidget
* parent
= 0 );
81 FormWidgetIface( QWidget
* w
, Okular::FormField
* ff
);
82 virtual ~FormWidgetIface();
84 Okular::NormalizedRect
rect() const;
85 void setWidthHeight( int w
, int h
);
86 void moveTo( int x
, int y
);
87 bool setVisibility( bool visible
);
88 void setCanBeFilled( bool fill
);
90 void setPageItem( PageViewItem
*pageItem
);
91 Okular::FormField
* formField() const;
92 PageViewItem
* pageItem() const;
94 virtual void setFormWidgetsController( FormWidgetsController
*controller
);
95 virtual QAbstractButton
* button();
98 FormWidgetsController
* m_controller
;
102 Okular::FormField
* m_ff
;
103 PageViewItem
* m_pageItem
;
107 class PushButtonEdit
: public QPushButton
, public FormWidgetIface
112 PushButtonEdit( Okular::FormFieldButton
* button
, QWidget
* parent
= 0 );
118 Okular::FormFieldButton
* m_form
;
121 class CheckBoxEdit
: public QCheckBox
, public FormWidgetIface
126 CheckBoxEdit( Okular::FormFieldButton
* button
, QWidget
* parent
= 0 );
128 // reimplemented from FormWidgetIface
129 void setFormWidgetsController( FormWidgetsController
*controller
);
130 QAbstractButton
* button();
133 void slotStateChanged( int state
);
136 Okular::FormFieldButton
* m_form
;
139 class RadioButtonEdit
: public QRadioButton
, public FormWidgetIface
144 RadioButtonEdit( Okular::FormFieldButton
* button
, QWidget
* parent
= 0 );
146 // reimplemented from FormWidgetIface
147 void setFormWidgetsController( FormWidgetsController
*controller
);
148 QAbstractButton
* button();
151 void slotToggled( bool checked
);
154 Okular::FormFieldButton
* m_form
;
157 class FormLineEdit
: public QLineEdit
, public FormWidgetIface
162 explicit FormLineEdit( Okular::FormFieldText
* text
, QWidget
* parent
= 0 );
165 void textEdited( const QString
& );
168 Okular::FormFieldText
* m_form
;
171 class TextAreaEdit
: public KTextEdit
, public FormWidgetIface
176 explicit TextAreaEdit( Okular::FormFieldText
* text
, QWidget
* parent
= 0 );
182 Okular::FormFieldText
* m_form
;
186 class FileEdit
: public KUrlRequester
, public FormWidgetIface
191 explicit FileEdit( Okular::FormFieldText
* text
, QWidget
* parent
= 0 );
194 void slotChanged( const QString
& );
197 Okular::FormFieldText
* m_form
;
201 class ListEdit
: public QListWidget
, public FormWidgetIface
206 explicit ListEdit( Okular::FormFieldChoice
* choice
, QWidget
* parent
= 0 );
209 void slotSelectionChanged();
212 Okular::FormFieldChoice
* m_form
;
216 class ComboEdit
: public QComboBox
, public FormWidgetIface
221 explicit ComboEdit( Okular::FormFieldChoice
* choice
, QWidget
* parent
= 0 );
224 void indexChanged( int );
227 Okular::FormFieldChoice
* m_form
;