25
25
#include < QPushButton>
26
26
#include < QLineEdit>
27
27
#include < QTextEdit>
28
- #include < QPlainTextEdit>
29
28
#include < QFileDialog>
30
29
#include < QComboBox>
31
30
#include < QCheckBox>
32
31
#include < QSpinBox>
33
32
#include < QCompleter>
34
33
#include < QHBoxLayout>
35
34
35
+ #if QT_VERSION >= 0x040400
36
+ #include < QPlainTextEdit>
37
+ #endif
38
+
36
39
void QgsAttributeEditor::selectFileName ( void )
37
40
{
38
41
QPushButton *pb = qobject_cast<QPushButton *>( sender () );
@@ -259,17 +262,26 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
259
262
{
260
263
QLineEdit *le = NULL ;
261
264
QTextEdit *te = NULL ;
265
+ #if QT_VERSION >= 0x040400
262
266
QPlainTextEdit *pte = NULL ;
267
+ #endif
263
268
264
269
if ( editor )
265
270
{
266
271
le = qobject_cast<QLineEdit *>( editor );
267
272
te = qobject_cast<QTextEdit *>( editor );
273
+ #if QT_VERSION >= 0x040400
268
274
pte = qobject_cast<QPlainTextEdit *>( editor );
275
+ #endif
269
276
}
270
277
else if ( editType == QgsVectorLayer::TextEdit )
271
278
{
279
+ #if QT_VERSION >= 0x040400
272
280
pte = new QPlainTextEdit ( parent );
281
+ #else
282
+ te = new QTextEdit ( parent );
283
+ te->setAcceptRichText ( false );
284
+ #endif
273
285
}
274
286
else
275
287
{
@@ -307,14 +319,18 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
307
319
308
320
if ( te )
309
321
{
322
+ #if QT_VERSION >= 0x040400
310
323
te->setAcceptRichText ( true );
324
+ #endif
311
325
myWidget = te;
312
326
}
313
327
328
+ #if QT_VERSION < 0x040400
314
329
if ( pte )
315
330
{
316
331
myWidget = pte;
317
332
}
333
+ #endif
318
334
}
319
335
break ;
320
336
@@ -390,14 +406,19 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
390
406
QTextEdit *te = qobject_cast<QTextEdit *>( widget );
391
407
if ( te )
392
408
{
409
+ #if QT_VERSION >= 0x040400
393
410
text = te->toHtml ();
411
+ #else
412
+ text = te->toPlainText ();
413
+ #endif
394
414
modified = te->document ()->isModified ();
395
415
if ( text == " NULL" )
396
416
{
397
417
text = QString::null;
398
418
}
399
419
}
400
420
421
+ #if QT_VERSION >= 0x040400
401
422
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( widget );
402
423
if ( pte )
403
424
{
@@ -408,6 +429,7 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
408
429
text = QString::null;
409
430
}
410
431
}
432
+ #endif
411
433
412
434
QComboBox *cb = qobject_cast<QComboBox *>( widget );
413
435
if ( cb )
@@ -574,9 +596,14 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
574
596
{
575
597
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
576
598
QTextEdit *te = qobject_cast<QTextEdit *>( editor );
599
+ #if QT_VERSION >= 0x040400
577
600
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor );
578
601
if ( !le && !te && !pte )
579
602
return false ;
603
+ #else
604
+ if ( !le && !te )
605
+ return false ;
606
+ #endif
580
607
581
608
QString text;
582
609
if ( value.isNull () )
@@ -589,10 +616,15 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
589
616
590
617
if ( le )
591
618
le->setText ( text );
619
+ #if QT_VERSION >= 0x040400
592
620
if ( te )
593
621
te->setHtml ( text );
594
622
if ( pte )
595
623
pte->setPlainText ( text );
624
+ #else
625
+ if ( te )
626
+ te->setPlainText ( text );
627
+ #endif
596
628
}
597
629
break ;
598
630
0 commit comments