2007-02-25 00:07:59 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _OKULAR_FORMWIDGETS_H_
|
|
|
|
#define _OKULAR_FORMWIDGETS_H_
|
|
|
|
|
|
|
|
#include "core/area.h"
|
|
|
|
|
2008-02-11 10:41:04 +00:00
|
|
|
#include <qcheckbox.h>
|
2007-02-25 00:07:59 +00:00
|
|
|
#include <qcombobox.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qlistwidget.h>
|
|
|
|
#include <qpushbutton.h>
|
2008-02-11 10:41:04 +00:00
|
|
|
#include <qradiobutton.h>
|
2007-02-25 00:07:59 +00:00
|
|
|
#include <ktextedit.h>
|
|
|
|
#include <kurlrequester.h>
|
|
|
|
|
2008-02-11 10:41:04 +00:00
|
|
|
class QButtonGroup;
|
2007-02-25 00:07:59 +00:00
|
|
|
class FormWidgetIface;
|
2007-10-18 22:09:49 +00:00
|
|
|
class PageViewItem;
|
2008-02-11 10:41:04 +00:00
|
|
|
class RadioButtonEdit;
|
2007-02-25 00:07:59 +00:00
|
|
|
|
|
|
|
namespace Okular {
|
|
|
|
class FormField;
|
2008-02-11 10:41:04 +00:00
|
|
|
class FormFieldButton;
|
2007-02-25 00:07:59 +00:00
|
|
|
class FormFieldChoice;
|
|
|
|
class FormFieldText;
|
|
|
|
}
|
|
|
|
|
2008-02-11 10:41:04 +00:00
|
|
|
struct RadioData
|
|
|
|
{
|
|
|
|
RadioData() {}
|
|
|
|
|
|
|
|
QList< int > ids;
|
|
|
|
QButtonGroup *group;
|
|
|
|
};
|
2007-10-18 22:09:49 +00:00
|
|
|
|
|
|
|
class FormWidgetsController : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
FormWidgetsController( QObject *parent = 0 );
|
|
|
|
virtual ~FormWidgetsController();
|
|
|
|
|
|
|
|
void signalChanged( FormWidgetIface *w );
|
|
|
|
|
2008-02-12 11:03:04 +00:00
|
|
|
QButtonGroup* registerRadioButton( FormWidgetIface* widget, const QList< int >& siblings );
|
2008-02-11 10:41:04 +00:00
|
|
|
void dropRadioButtons();
|
|
|
|
|
2007-10-18 22:09:49 +00:00
|
|
|
signals:
|
|
|
|
void changed( FormWidgetIface *w );
|
2008-02-11 10:41:04 +00:00
|
|
|
|
2008-03-07 16:07:15 +00:00
|
|
|
private slots:
|
|
|
|
void slotButtonClicked( QAbstractButton *button );
|
|
|
|
|
2008-02-11 10:41:04 +00:00
|
|
|
private:
|
|
|
|
QList< RadioData > m_radios;
|
2007-10-18 22:09:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-02-25 00:07:59 +00:00
|
|
|
class FormWidgetFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static FormWidgetIface * createWidget( Okular::FormField * ff, QWidget * parent = 0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FormWidgetIface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FormWidgetIface( QWidget * w, Okular::FormField * ff );
|
|
|
|
virtual ~FormWidgetIface();
|
|
|
|
|
|
|
|
Okular::NormalizedRect rect() const;
|
|
|
|
void setWidthHeight( int w, int h );
|
|
|
|
void moveTo( int x, int y );
|
2007-02-25 14:59:26 +00:00
|
|
|
bool setVisibility( bool visible );
|
2007-04-28 23:22:20 +00:00
|
|
|
void setCanBeFilled( bool fill );
|
2007-02-25 00:07:59 +00:00
|
|
|
|
2007-10-18 22:09:49 +00:00
|
|
|
void setPageItem( PageViewItem *pageItem );
|
2008-02-12 11:03:04 +00:00
|
|
|
Okular::FormField* formField() const;
|
2007-10-18 22:09:49 +00:00
|
|
|
PageViewItem* pageItem() const;
|
|
|
|
|
2008-02-11 10:41:04 +00:00
|
|
|
virtual void setFormWidgetsController( FormWidgetsController *controller );
|
2008-02-12 11:03:04 +00:00
|
|
|
virtual QAbstractButton* button();
|
2007-10-18 22:09:49 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
FormWidgetsController * m_controller;
|
|
|
|
|
2007-02-25 00:07:59 +00:00
|
|
|
private:
|
|
|
|
QWidget * m_widget;
|
|
|
|
Okular::FormField * m_ff;
|
2007-10-18 22:09:49 +00:00
|
|
|
PageViewItem * m_pageItem;
|
2007-02-25 00:07:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-02-11 10:41:04 +00:00
|
|
|
class PushButtonEdit : public QPushButton, public FormWidgetIface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
PushButtonEdit( Okular::FormFieldButton * button, QWidget * parent = 0 );
|
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::FormFieldButton * m_form;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CheckBoxEdit : public QCheckBox, public FormWidgetIface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
CheckBoxEdit( Okular::FormFieldButton * button, QWidget * parent = 0 );
|
|
|
|
|
2008-02-12 11:03:04 +00:00
|
|
|
// reimplemented from FormWidgetIface
|
|
|
|
void setFormWidgetsController( FormWidgetsController *controller );
|
|
|
|
QAbstractButton* button();
|
|
|
|
|
2008-02-11 10:41:04 +00:00
|
|
|
private slots:
|
|
|
|
void slotStateChanged( int state );
|
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::FormFieldButton * m_form;
|
|
|
|
};
|
|
|
|
|
|
|
|
class RadioButtonEdit : public QRadioButton, public FormWidgetIface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
RadioButtonEdit( Okular::FormFieldButton * button, QWidget * parent = 0 );
|
|
|
|
|
|
|
|
// reimplemented from FormWidgetIface
|
|
|
|
void setFormWidgetsController( FormWidgetsController *controller );
|
2008-02-12 11:03:04 +00:00
|
|
|
QAbstractButton* button();
|
2008-02-11 10:41:04 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void slotToggled( bool checked );
|
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::FormFieldButton * m_form;
|
|
|
|
};
|
|
|
|
|
2007-02-25 00:07:59 +00:00
|
|
|
class FormLineEdit : public QLineEdit, public FormWidgetIface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2007-04-15 19:11:10 +00:00
|
|
|
explicit FormLineEdit( Okular::FormFieldText * text, QWidget * parent = 0 );
|
2007-02-25 00:07:59 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void textEdited( const QString& );
|
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::FormFieldText * m_form;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TextAreaEdit : public KTextEdit, public FormWidgetIface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2007-04-15 19:11:10 +00:00
|
|
|
explicit TextAreaEdit( Okular::FormFieldText * text, QWidget * parent = 0 );
|
2007-02-25 00:07:59 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void slotChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::FormFieldText * m_form;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FileEdit : public KUrlRequester, public FormWidgetIface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2007-04-15 19:11:10 +00:00
|
|
|
explicit FileEdit( Okular::FormFieldText * text, QWidget * parent = 0 );
|
2007-02-25 00:07:59 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void slotChanged( const QString& );
|
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::FormFieldText * m_form;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ListEdit : public QListWidget, public FormWidgetIface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2007-04-15 19:11:10 +00:00
|
|
|
explicit ListEdit( Okular::FormFieldChoice * choice, QWidget * parent = 0 );
|
2007-02-25 00:07:59 +00:00
|
|
|
|
|
|
|
private slots:
|
2007-11-24 16:41:57 +00:00
|
|
|
void slotSelectionChanged();
|
2007-02-25 00:07:59 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::FormFieldChoice * m_form;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ComboEdit : public QComboBox, public FormWidgetIface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2007-04-15 19:11:10 +00:00
|
|
|
explicit ComboEdit( Okular::FormFieldChoice * choice, QWidget * parent = 0 );
|
2007-02-25 00:07:59 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void indexChanged( int );
|
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::FormFieldChoice * m_form;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|