~ubuntu-branches/debian/stretch/qpdfview/stretch

« back to all changes in this revision

Viewing changes to sources/formfieldwidgets.cpp

  • Committer: Package Import Robot
  • Author(s): Benjamin Eltzner
  • Date: 2015-03-22 11:42:36 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20150322114236-81p4twy532ytw10m
Tags: 0.4.14-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include <poppler-form.h>
28
28
 
 
29
#ifndef HAS_POPPLER_24
 
30
 
 
31
#define LOCK_FORM_FIELD QMutexLocker mutexLocker(m_mutex);
 
32
 
 
33
#else
 
34
 
 
35
#define LOCK_FORM_FIELD
 
36
 
 
37
#endif // HAS_POPPLER_24
 
38
 
29
39
namespace
30
40
{
31
41
 
51
61
    m_mutex(mutex),
52
62
    m_formField(formField)
53
63
{
54
 
#ifndef HAS_POPPLER_24
55
 
 
56
 
    QMutexLocker mutexLocker(m_mutex);
57
 
 
58
 
#endif // HAS_POPPLER_24
 
64
    LOCK_FORM_FIELD
59
65
 
60
66
    setText(m_formField->text());
61
67
    setMaxLength(m_formField->maximumLength());
78
84
 
79
85
void NormalTextFieldWidget::on_textChanged(const QString& text)
80
86
{
81
 
#ifndef HAS_POPPLER_24
82
 
 
83
 
    QMutexLocker mutexLocker(m_mutex);
84
 
 
85
 
#endif // HAS_POPPLER_24
 
87
    LOCK_FORM_FIELD
86
88
 
87
89
    m_formField->setText(text);
88
90
}
91
93
    m_mutex(mutex),
92
94
    m_formField(formField)
93
95
{
94
 
#ifndef HAS_POPPLER_24
95
 
 
96
 
    QMutexLocker mutexLocker(m_mutex);
97
 
 
98
 
#endif // HAS_POPPLER_24
 
96
    LOCK_FORM_FIELD
99
97
 
100
98
    setPlainText(m_formField->text());
101
99
 
115
113
 
116
114
void MultilineTextFieldWidget::on_textChanged()
117
115
{
118
 
#ifndef HAS_POPPLER_24
119
 
 
120
 
    QMutexLocker mutexLocker(m_mutex);
121
 
 
122
 
#endif // HAS_POPPLER_24
 
116
    LOCK_FORM_FIELD
123
117
 
124
118
    m_formField->setText(toPlainText());
125
119
}
128
122
    m_mutex(mutex),
129
123
    m_formField(formField)
130
124
{
131
 
#ifndef HAS_POPPLER_24
132
 
 
133
 
    QMutexLocker mutexLocker(m_mutex);
134
 
 
135
 
#endif // HAS_POPPLER_24
 
125
    LOCK_FORM_FIELD
136
126
 
137
127
    addItems(m_formField->choices());
138
128
 
194
184
 
195
185
void ComboBoxChoiceFieldWidget::on_currentIndexChanged(int index)
196
186
{
197
 
#ifndef HAS_POPPLER_24
198
 
 
199
 
    QMutexLocker mutexLocker(m_mutex);
200
 
 
201
 
#endif // HAS_POPPLER_24
 
187
    LOCK_FORM_FIELD
202
188
 
203
189
    m_formField->setCurrentChoices(QList< int >() << index);
204
190
}
205
191
 
206
192
void ComboBoxChoiceFieldWidget::on_currentTextChanged(const QString& text)
207
193
{
208
 
#ifndef HAS_POPPLER_24
209
 
 
210
 
    QMutexLocker mutexLocker(m_mutex);
211
 
 
212
 
#endif // HAS_POPPLER_24
 
194
    LOCK_FORM_FIELD
213
195
 
214
196
#ifdef HAS_POPPLER_22
215
197
 
222
204
    m_mutex(mutex),
223
205
    m_formField(formField)
224
206
{
225
 
#ifndef HAS_POPPLER_24
226
 
 
227
 
    QMutexLocker mutexLocker(m_mutex);
228
 
 
229
 
#endif // HAS_POPPLER_24
 
207
    LOCK_FORM_FIELD
230
208
 
231
209
    addItems(m_formField->choices());
232
210
    setSelectionMode(m_formField->multiSelect() ? QAbstractItemView::MultiSelection : QAbstractItemView::SingleSelection);
253
231
 
254
232
void ListBoxChoiceFieldWidget::on_itemSelectionChanged()
255
233
{
256
 
#ifndef HAS_POPPLER_24
257
 
 
258
 
    QMutexLocker mutexLocker(m_mutex);
259
 
 
260
 
#endif // HAS_POPPLER_24
 
234
    LOCK_FORM_FIELD
261
235
 
262
236
    QList< int > currentChoices;
263
237
 
276
250
    m_mutex(mutex),
277
251
    m_formField(formField)
278
252
{
279
 
#ifndef HAS_POPPLER_24
280
 
 
281
 
    QMutexLocker mutexLocker(m_mutex);
282
 
 
283
 
#endif // HAS_POPPLER_24
 
253
    LOCK_FORM_FIELD
284
254
 
285
255
    setChecked(m_formField->state());
286
256
 
298
268
 
299
269
void CheckBoxChoiceFieldWidget::on_toggled(bool checked)
300
270
{
301
 
#ifndef HAS_POPPLER_24
302
 
 
303
 
    QMutexLocker mutexLocker(m_mutex);
304
 
 
305
 
#endif // HAS_POPPLER_24
 
271
    LOCK_FORM_FIELD
306
272
 
307
273
    m_formField->setState(checked);
308
274
}
313
279
    m_mutex(mutex),
314
280
    m_formField(formField)
315
281
{
316
 
#ifndef HAS_POPPLER_24
317
 
 
318
 
    QMutexLocker mutexLocker(m_mutex);
319
 
 
320
 
#endif // HAS_POPPLER_24
 
282
    LOCK_FORM_FIELD
321
283
 
322
284
    s_siblings.insert(qMakePair(m_mutex, m_formField->id()), this);
323
285
 
330
292
 
331
293
RadioChoiceFieldWidget::~RadioChoiceFieldWidget()
332
294
{
333
 
#ifndef HAS_POPPLER_24
334
 
 
335
 
    QMutexLocker mutexLocker(m_mutex);
336
 
 
337
 
#endif // HAS_POPPLER_24
 
295
    LOCK_FORM_FIELD
338
296
 
339
297
    s_siblings.remove(qMakePair(m_mutex, m_formField->id()));
340
298
}
349
307
 
350
308
void RadioChoiceFieldWidget::on_toggled(bool checked)
351
309
{
352
 
#ifndef HAS_POPPLER_24
353
 
 
354
 
    m_mutex->lock();
355
 
 
356
 
#endif // HAS_POPPLER_24
357
 
 
358
 
    const QList< int > siblings = m_formField->siblings();
 
310
    LOCK_FORM_FIELD
359
311
 
360
312
    m_formField->setState(checked);
361
313
 
362
 
#ifndef HAS_POPPLER_24
363
 
 
364
 
    m_mutex->unlock();
365
 
 
366
 
#endif // HAS_POPPLER_24
367
 
 
368
314
    if(checked)
369
315
    {
 
316
        const QList< int > siblings = m_formField->siblings();
 
317
 
 
318
#ifndef HAS_POPPLER_24
 
319
 
 
320
        mutexLocker.unlock();
 
321
 
 
322
#endif // HAS_POPPLER_24
 
323
 
370
324
        foreach(int id, siblings)
371
325
        {
372
 
            QPair< QMutex*, int > key = qMakePair(m_mutex, id);
 
326
            const QPair< QMutex*, int > key = qMakePair(m_mutex, id);
373
327
 
374
328
            if(s_siblings.contains(key))
375
329
            {