1 | /* |
---|
2 | |
---|
3 | Copyright 2012-2013 Adam Reichold |
---|
4 | |
---|
5 | This file is part of qpdfview. |
---|
6 | |
---|
7 | qpdfview is free software: you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU General Public License as published by |
---|
9 | the Free Software Foundation, either version 2 of the License, or |
---|
10 | (at your option) any later version. |
---|
11 | |
---|
12 | qpdfview is distributed in the hope that it will be useful, |
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | GNU General Public License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU General Public License |
---|
18 | along with qpdfview. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef FORMFIELDWIDGETS_H |
---|
23 | #define FORMFIELDWIDGETS_H |
---|
24 | |
---|
25 | #include <QCheckBox> |
---|
26 | #include <QComboBox> |
---|
27 | #include <QLineEdit> |
---|
28 | #include <QListWidget> |
---|
29 | #include <QPlainTextEdit> |
---|
30 | #include <QRadioButton> |
---|
31 | |
---|
32 | class QMutex; |
---|
33 | |
---|
34 | namespace Poppler |
---|
35 | { |
---|
36 | class FormField; |
---|
37 | class FormFieldText; |
---|
38 | class FormFieldChoice; |
---|
39 | class FormFieldButton; |
---|
40 | } |
---|
41 | |
---|
42 | namespace qpdfview |
---|
43 | { |
---|
44 | |
---|
45 | class NormalTextFieldWidget : public QLineEdit |
---|
46 | { |
---|
47 | Q_OBJECT |
---|
48 | |
---|
49 | public: |
---|
50 | NormalTextFieldWidget(QMutex* mutex, Poppler::FormFieldText* formField, QWidget* parent = 0); |
---|
51 | |
---|
52 | signals: |
---|
53 | void wasModified(); |
---|
54 | |
---|
55 | protected: |
---|
56 | void keyPressEvent(QKeyEvent* event); |
---|
57 | |
---|
58 | protected slots: |
---|
59 | void on_textChanged(const QString& text); |
---|
60 | |
---|
61 | private: |
---|
62 | Q_DISABLE_COPY(NormalTextFieldWidget) |
---|
63 | |
---|
64 | QMutex* m_mutex; |
---|
65 | Poppler::FormFieldText* m_formField; |
---|
66 | |
---|
67 | }; |
---|
68 | |
---|
69 | class MultilineTextFieldWidget : public QPlainTextEdit |
---|
70 | { |
---|
71 | Q_OBJECT |
---|
72 | |
---|
73 | public: |
---|
74 | MultilineTextFieldWidget(QMutex* mutex, Poppler::FormFieldText* formField, QWidget* parent = 0); |
---|
75 | |
---|
76 | signals: |
---|
77 | void wasModified(); |
---|
78 | |
---|
79 | protected: |
---|
80 | void keyPressEvent(QKeyEvent* event); |
---|
81 | |
---|
82 | protected slots: |
---|
83 | void on_textChanged(); |
---|
84 | |
---|
85 | private: |
---|
86 | Q_DISABLE_COPY(MultilineTextFieldWidget) |
---|
87 | |
---|
88 | QMutex* m_mutex; |
---|
89 | Poppler::FormFieldText* m_formField; |
---|
90 | |
---|
91 | }; |
---|
92 | |
---|
93 | class ComboBoxChoiceFieldWidget : public QComboBox |
---|
94 | { |
---|
95 | Q_OBJECT |
---|
96 | |
---|
97 | public: |
---|
98 | ComboBoxChoiceFieldWidget(QMutex* mutex, Poppler::FormFieldChoice* formField, QWidget* parent = 0); |
---|
99 | |
---|
100 | signals: |
---|
101 | void wasModified(); |
---|
102 | |
---|
103 | protected: |
---|
104 | void keyPressEvent(QKeyEvent* event); |
---|
105 | |
---|
106 | void showPopup(); |
---|
107 | void hidePopup(); |
---|
108 | |
---|
109 | protected slots: |
---|
110 | void on_currentIndexChanged(int index); |
---|
111 | void on_currentTextChanged(const QString& text); |
---|
112 | |
---|
113 | private: |
---|
114 | Q_DISABLE_COPY(ComboBoxChoiceFieldWidget) |
---|
115 | |
---|
116 | QMutex* m_mutex; |
---|
117 | Poppler::FormFieldChoice* m_formField; |
---|
118 | |
---|
119 | }; |
---|
120 | |
---|
121 | class ListBoxChoiceFieldWidget : public QListWidget |
---|
122 | { |
---|
123 | Q_OBJECT |
---|
124 | |
---|
125 | public: |
---|
126 | ListBoxChoiceFieldWidget(QMutex* mutex, Poppler::FormFieldChoice* formField, QWidget* parent = 0); |
---|
127 | |
---|
128 | signals: |
---|
129 | void wasModified(); |
---|
130 | |
---|
131 | protected: |
---|
132 | void keyPressEvent(QKeyEvent* event); |
---|
133 | |
---|
134 | protected slots: |
---|
135 | void on_itemSelectionChanged(); |
---|
136 | |
---|
137 | private: |
---|
138 | Q_DISABLE_COPY(ListBoxChoiceFieldWidget) |
---|
139 | |
---|
140 | QMutex* m_mutex; |
---|
141 | Poppler::FormFieldChoice* m_formField; |
---|
142 | |
---|
143 | }; |
---|
144 | |
---|
145 | class CheckBoxChoiceFieldWidget : public QCheckBox |
---|
146 | { |
---|
147 | Q_OBJECT |
---|
148 | |
---|
149 | public: |
---|
150 | CheckBoxChoiceFieldWidget(QMutex* mutex, Poppler::FormFieldButton* formField, QWidget* parent = 0); |
---|
151 | |
---|
152 | signals: |
---|
153 | void wasModified(); |
---|
154 | |
---|
155 | protected: |
---|
156 | void keyPressEvent(QKeyEvent* event); |
---|
157 | |
---|
158 | protected slots: |
---|
159 | void on_toggled(bool checked); |
---|
160 | |
---|
161 | protected slots: |
---|
162 | |
---|
163 | private: |
---|
164 | Q_DISABLE_COPY(CheckBoxChoiceFieldWidget) |
---|
165 | |
---|
166 | QMutex* m_mutex; |
---|
167 | Poppler::FormFieldButton* m_formField; |
---|
168 | |
---|
169 | }; |
---|
170 | |
---|
171 | class RadioChoiceFieldWidget : public QRadioButton |
---|
172 | { |
---|
173 | Q_OBJECT |
---|
174 | |
---|
175 | public: |
---|
176 | RadioChoiceFieldWidget(QMutex* mutex, Poppler::FormFieldButton* formField, QWidget* parent = 0); |
---|
177 | ~RadioChoiceFieldWidget(); |
---|
178 | |
---|
179 | signals: |
---|
180 | void wasModified(); |
---|
181 | |
---|
182 | protected: |
---|
183 | void keyPressEvent(QKeyEvent* event); |
---|
184 | |
---|
185 | protected slots: |
---|
186 | void on_toggled(bool checked); |
---|
187 | |
---|
188 | private: |
---|
189 | Q_DISABLE_COPY(RadioChoiceFieldWidget) |
---|
190 | |
---|
191 | typedef QMap< QPair< QMutex*, int >, RadioChoiceFieldWidget* > Siblings; |
---|
192 | static Siblings s_siblings; |
---|
193 | |
---|
194 | QMutex* m_mutex; |
---|
195 | Poppler::FormFieldButton* m_formField; |
---|
196 | |
---|
197 | }; |
---|
198 | |
---|
199 | } // qpdfview |
---|
200 | |
---|
201 | #endif // FORMFIELDWIDGETS_H |
---|