Skip to content

Commit

Permalink
Make QgsDxfExport Qt6 ready
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn authored and nyalldawson committed Mar 25, 2021
1 parent 929b708 commit a379e1e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/core/auto_generated/dxf/qgsdxfexport.sip.in
Expand Up @@ -302,6 +302,18 @@ Write a tuple of group code and integer value
:param code: group code
:param i: integer value

.. note::

available in Python bindings as writeGroupInt
%End

void writeGroup( int code, long long i ) /PyName=writeGroupLong/;
%Docstring
Write a tuple of group code and long value

:param code: group code
:param i: integer value

.. note::

available in Python bindings as writeGroupInt
Expand Down
12 changes: 12 additions & 0 deletions src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -105,6 +105,12 @@ void QgsDxfExport::writeGroup( int code, int i )
writeInt( i );
}

void QgsDxfExport::writeGroup( int code, long long i )
{
writeGroupCode( code );
writeInt( i );
}

void QgsDxfExport::writeGroup( int code, double d )
{
writeGroupCode( code );
Expand Down Expand Up @@ -190,7 +196,11 @@ QgsDxfExport::ExportResult QgsDxfExport::writeToFile( QIODevice *d, const QStrin
}

mTextStream.setDevice( d );
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
mTextStream.setCodec( encoding.toLocal8Bit() );
#else
mTextStream.setEncoding( QStringConverter::encodingForName( encoding.toLocal8Bit() ).value_or( QStringConverter::Utf8 ) );
#endif

if ( mCrs.isValid() )
mMapSettings.setDestinationCrs( mCrs );
Expand Down Expand Up @@ -1488,12 +1498,14 @@ void QgsDxfExport::writeText( const QString &layer, const QString &text, const Q

void QgsDxfExport::writeMText( const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color )
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if ( !mTextStream.codec()->canEncode( text ) )
{
// TODO return error
QgsDebugMsg( QStringLiteral( "could not encode:%1" ).arg( text ) );
return;
}
#endif

writeGroup( 0, QStringLiteral( "MTEXT" ) );
writeHandle();
Expand Down
8 changes: 8 additions & 0 deletions src/core/dxf/qgsdxfexport.h
Expand Up @@ -332,6 +332,14 @@ class CORE_EXPORT QgsDxfExport : public QgsLabelSink
*/
void writeGroup( int code, int i ) SIP_PYNAME( writeGroupInt );

/**
* Write a tuple of group code and long value
* \param code group code
* \param i integer value
* \note available in Python bindings as writeGroupInt
*/
void writeGroup( int code, long long i ) SIP_PYNAME( writeGroupLong );

/**
* Write a group code with a floating point value
* \param code group code
Expand Down

0 comments on commit a379e1e

Please sign in to comment.