Skip to content

Commit

Permalink
hopefully restore Qt 4.3 compability
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12198 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 19, 2009
1 parent b2a479c commit 674cec9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -4879,7 +4879,11 @@ void QgisApp::loadPythonSupport()
#endif
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 );
QgsDebugMsg( QString( "load library %1 (%2)" ).arg( pythonlibName ).arg( version ) );
#if QT_VERSION >= 0x040400
QLibrary pythonlib( pythonlibName, version );
#else
QLibrary pythonlib( pythonlibName );
#endif
// It's necessary to set these two load hints, otherwise Python library won't work correctly
// see http://lists.kde.org/?l=pykde&m=117190116820758&w=2
pythonlib.setLoadHints( QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint );
Expand Down
34 changes: 33 additions & 1 deletion src/app/qgsattributeeditor.cpp
Expand Up @@ -25,14 +25,17 @@
#include <QPushButton>
#include <QLineEdit>
#include <QTextEdit>
#include <QPlainTextEdit>
#include <QFileDialog>
#include <QComboBox>
#include <QCheckBox>
#include <QSpinBox>
#include <QCompleter>
#include <QHBoxLayout>

#if QT_VERSION >= 0x040400
#include <QPlainTextEdit>
#endif

void QgsAttributeEditor::selectFileName( void )
{
QPushButton *pb = qobject_cast<QPushButton *>( sender() );
Expand Down Expand Up @@ -259,17 +262,26 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
{
QLineEdit *le = NULL;
QTextEdit *te = NULL;
#if QT_VERSION >= 0x040400
QPlainTextEdit *pte = NULL;
#endif

if ( editor )
{
le = qobject_cast<QLineEdit *>( editor );
te = qobject_cast<QTextEdit *>( editor );
#if QT_VERSION >= 0x040400
pte = qobject_cast<QPlainTextEdit *>( editor );
#endif
}
else if ( editType == QgsVectorLayer::TextEdit )
{
#if QT_VERSION >= 0x040400
pte = new QPlainTextEdit( parent );
#else
te = new QTextEdit( parent );
te->setAcceptRichText( false );
#endif
}
else
{
Expand Down Expand Up @@ -307,14 +319,18 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed

if ( te )
{
#if QT_VERSION >= 0x040400
te->setAcceptRichText( true );
#endif
myWidget = te;
}

#if QT_VERSION < 0x040400
if ( pte )
{
myWidget = pte;
}
#endif
}
break;

Expand Down Expand Up @@ -390,14 +406,19 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
QTextEdit *te = qobject_cast<QTextEdit *>( widget );
if ( te )
{
#if QT_VERSION >= 0x040400
text = te->toHtml();
#else
text = te->toPlainText();
#endif
modified = te->document()->isModified();
if ( text == "NULL" )
{
text = QString::null;
}
}

#if QT_VERSION >= 0x040400
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( widget );
if ( pte )
{
Expand All @@ -408,6 +429,7 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
text = QString::null;
}
}
#endif

QComboBox *cb = qobject_cast<QComboBox *>( widget );
if ( cb )
Expand Down Expand Up @@ -574,9 +596,14 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
{
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
QTextEdit *te = qobject_cast<QTextEdit *>( editor );
#if QT_VERSION >= 0x040400
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor );
if ( !le && !te && !pte )
return false;
#else
if ( !le && !te )
return false;
#endif

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

if ( le )
le->setText( text );
#if QT_VERSION >= 0x040400
if ( te )
te->setHtml( text );
if ( pte )
pte->setPlainText( text );
#else
if ( te )
te->setPlainText( text );
#endif
}
break;

Expand Down

0 comments on commit 674cec9

Please sign in to comment.