Skip to content

Commit 1cb41ab

Browse files
author
jef
committed
hopefully restore Qt 4.3 compability
git-svn-id: http://svn.osgeo.org/qgis/trunk@12198 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent c24f308 commit 1cb41ab

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/app/qgisapp.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -4879,7 +4879,11 @@ void QgisApp::loadPythonSupport()
48794879
#endif
48804880
QString version = QString( "%1.%2.%3" ).arg( QGis::QGIS_VERSION_INT / 10000 ).arg( QGis::QGIS_VERSION_INT / 100 % 100 ).arg( QGis::QGIS_VERSION_INT % 100 );
48814881
QgsDebugMsg( QString( "load library %1 (%2)" ).arg( pythonlibName ).arg( version ) );
4882+
#if QT_VERSION >= 0x040400
48824883
QLibrary pythonlib( pythonlibName, version );
4884+
#else
4885+
QLibrary pythonlib( pythonlibName );
4886+
#endif
48834887
// It's necessary to set these two load hints, otherwise Python library won't work correctly
48844888
// see http://lists.kde.org/?l=pykde&m=117190116820758&w=2
48854889
pythonlib.setLoadHints( QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint );

src/app/qgsattributeeditor.cpp

+33-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@
2525
#include <QPushButton>
2626
#include <QLineEdit>
2727
#include <QTextEdit>
28-
#include <QPlainTextEdit>
2928
#include <QFileDialog>
3029
#include <QComboBox>
3130
#include <QCheckBox>
3231
#include <QSpinBox>
3332
#include <QCompleter>
3433
#include <QHBoxLayout>
3534

35+
#if QT_VERSION >= 0x040400
36+
#include <QPlainTextEdit>
37+
#endif
38+
3639
void QgsAttributeEditor::selectFileName( void )
3740
{
3841
QPushButton *pb = qobject_cast<QPushButton *>( sender() );
@@ -259,17 +262,26 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
259262
{
260263
QLineEdit *le = NULL;
261264
QTextEdit *te = NULL;
265+
#if QT_VERSION >= 0x040400
262266
QPlainTextEdit *pte = NULL;
267+
#endif
263268

264269
if ( editor )
265270
{
266271
le = qobject_cast<QLineEdit *>( editor );
267272
te = qobject_cast<QTextEdit *>( editor );
273+
#if QT_VERSION >= 0x040400
268274
pte = qobject_cast<QPlainTextEdit *>( editor );
275+
#endif
269276
}
270277
else if ( editType == QgsVectorLayer::TextEdit )
271278
{
279+
#if QT_VERSION >= 0x040400
272280
pte = new QPlainTextEdit( parent );
281+
#else
282+
te = new QTextEdit( parent );
283+
te->setAcceptRichText( false );
284+
#endif
273285
}
274286
else
275287
{
@@ -307,14 +319,18 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
307319

308320
if ( te )
309321
{
322+
#if QT_VERSION >= 0x040400
310323
te->setAcceptRichText( true );
324+
#endif
311325
myWidget = te;
312326
}
313327

328+
#if QT_VERSION < 0x040400
314329
if ( pte )
315330
{
316331
myWidget = pte;
317332
}
333+
#endif
318334
}
319335
break;
320336

@@ -390,14 +406,19 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
390406
QTextEdit *te = qobject_cast<QTextEdit *>( widget );
391407
if ( te )
392408
{
409+
#if QT_VERSION >= 0x040400
393410
text = te->toHtml();
411+
#else
412+
text = te->toPlainText();
413+
#endif
394414
modified = te->document()->isModified();
395415
if ( text == "NULL" )
396416
{
397417
text = QString::null;
398418
}
399419
}
400420

421+
#if QT_VERSION >= 0x040400
401422
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( widget );
402423
if ( pte )
403424
{
@@ -408,6 +429,7 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
408429
text = QString::null;
409430
}
410431
}
432+
#endif
411433

412434
QComboBox *cb = qobject_cast<QComboBox *>( widget );
413435
if ( cb )
@@ -574,9 +596,14 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
574596
{
575597
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
576598
QTextEdit *te = qobject_cast<QTextEdit *>( editor );
599+
#if QT_VERSION >= 0x040400
577600
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor );
578601
if ( !le && !te && !pte )
579602
return false;
603+
#else
604+
if ( !le && !te )
605+
return false;
606+
#endif
580607

581608
QString text;
582609
if ( value.isNull() )
@@ -589,10 +616,15 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
589616

590617
if ( le )
591618
le->setText( text );
619+
#if QT_VERSION >= 0x040400
592620
if ( te )
593621
te->setHtml( text );
594622
if ( pte )
595623
pte->setPlainText( text );
624+
#else
625+
if ( te )
626+
te->setPlainText( text );
627+
#endif
596628
}
597629
break;
598630

0 commit comments

Comments
 (0)