Skip to content

Commit 03ec2d8

Browse files
authoredNov 24, 2017
Merge pull request #5702 from nyalldawson/dxf_improve
[dxf] Add option to export labels as text elements, instead of mtext
2 parents 2b5aca5 + f8d8395 commit 03ec2d8

File tree

13 files changed

+725
-280
lines changed

13 files changed

+725
-280
lines changed
 

‎python/core/dxf/qgsdxfexport.sip

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ class QgsDxfExport
2727
SymbolLayerSymbology
2828
};
2929

30+
enum Flag
31+
{
32+
FlagNoMText,
33+
};
34+
typedef QFlags<QgsDxfExport::Flag> Flags;
35+
36+
3037
QgsDxfExport();
3138
%Docstring
3239
Constructor for QgsDxfExport.
@@ -38,6 +45,21 @@ class QgsDxfExport
3845
\param settings map settings to apply
3946
%End
4047

48+
void setFlags( QgsDxfExport::Flags flags );
49+
%Docstring
50+
Sets the export flags.
51+
.. versionadded:: 3.0
52+
.. seealso:: flags()
53+
%End
54+
55+
QgsDxfExport::Flags flags() const;
56+
%Docstring
57+
Returns the export flags.
58+
.. versionadded:: 3.0
59+
.. seealso:: setFlags()
60+
:rtype: QgsDxfExport.Flags
61+
%End
62+
4163
void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
4264
%Docstring
4365
Add layers to export
@@ -342,6 +364,9 @@ return list of available DXF encodings
342364

343365
};
344366

367+
QFlags<QgsDxfExport::Flag> operator|(QgsDxfExport::Flag f1, QFlags<QgsDxfExport::Flag> f2);
368+
369+
345370
/************************************************************************
346371
* This file has been generated automatically from *
347372
* *

‎src/app/qgisapp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5700,6 +5700,12 @@ void QgisApp::dxfExport()
57005700
dxfExport.setLayerTitleAsName( d.layerTitleAsName() );
57015701
dxfExport.setDestinationCrs( d.crs() );
57025702
dxfExport.setForce2d( d.force2d() );
5703+
5704+
QgsDxfExport::Flags flags = 0;
5705+
if ( !d.useMText() )
5706+
flags = flags | QgsDxfExport::FlagNoMText;
5707+
dxfExport.setFlags( flags );
5708+
57035709
if ( mapCanvas() )
57045710
{
57055711
//extent

‎src/app/qgscrashhandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class APP_EXPORT QgsCrashHandler
3131
{
3232

3333
public:
34+
3435
/**
3536
* This class doesn't need to be created by anyone as is only used to handle
3637
* crashes in the application.

‎src/app/qgsdxfexportdialog.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
458458
mScaleWidget->setScale( 1.0 / oldScale );
459459
mLayerTitleAsName->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfLayerTitleAsName" ), s.value( QStringLiteral( "qgis/lastDxfLayerTitleAsName" ), "false" ).toString() ) != QLatin1String( "false" ) );
460460
mMapExtentCheckBox->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfMapRectangle" ), s.value( QStringLiteral( "qgis/lastDxfMapRectangle" ), "false" ).toString() ) != QLatin1String( "false" ) );
461+
mMTextCheckBox->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfUseMText" ), s.value( QStringLiteral( "qgis/lastDxfUseMText" ), "true" ).toString() ) != QLatin1String( "false" ) );
461462

462463
QStringList ids = QgsProject::instance()->mapThemeCollection()->mapThemes();
463464
ids.prepend( QLatin1String( "" ) );
@@ -611,6 +612,11 @@ bool QgsDxfExportDialog::force2d() const
611612
return mForce2d->isChecked();
612613
}
613614

615+
bool QgsDxfExportDialog::useMText() const
616+
{
617+
return mMTextCheckBox->isChecked();
618+
}
619+
614620
void QgsDxfExportDialog::saveSettings()
615621
{
616622
QgsSettings s;
@@ -622,6 +628,7 @@ void QgsDxfExportDialog::saveSettings()
622628
s.setValue( QStringLiteral( "qgis/lastDxfLayerTitleAsName" ), mLayerTitleAsName->isChecked() );
623629
s.setValue( QStringLiteral( "qgis/lastDxfEncoding" ), mEncoding->currentText() );
624630
s.setValue( QStringLiteral( "qgis/lastDxfCrs" ), QString::number( mCRS.srsid() ) );
631+
s.setValue( QStringLiteral( "qgis/lastDxfUseMText" ), mMTextCheckBox->isChecked() );
625632

626633
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfSymbologyMode" ), mSymbologyModeComboBox->currentIndex() );
627634
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastSymbologyExportScale" ), mScaleWidget->scale() != 0 ? 1.0 / mScaleWidget->scale() : 0 );
@@ -630,6 +637,7 @@ void QgsDxfExportDialog::saveSettings()
630637
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfEncoding" ), mEncoding->currentText() );
631638
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastVisibilityPreset" ), mVisibilityPresets->currentText() );
632639
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfCrs" ), QString::number( mCRS.srsid() ) );
640+
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfUseMText" ), mMTextCheckBox->isChecked() );
633641
}
634642

635643

‎src/app/qgsdxfexportdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
8888
bool exportMapExtent() const;
8989
bool layerTitleAsName() const;
9090
bool force2d() const;
91+
bool useMText() const;
9192
QString mapTheme() const;
9293
QString encoding() const;
9394
QgsCoordinateReferenceSystem crs() const;

‎src/core/dxf/qgsdxfexport.cpp

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,16 @@ void QgsDxfExport::setMapSettings( const QgsMapSettings &settings )
389389
mMapSettings = settings;
390390
}
391391

392+
void QgsDxfExport::setFlags( QgsDxfExport::Flags flags )
393+
{
394+
mFlags = flags;
395+
}
396+
397+
QgsDxfExport::Flags QgsDxfExport::flags() const
398+
{
399+
return mFlags;
400+
}
401+
392402
void QgsDxfExport::addLayers( const QList< QPair< QgsVectorLayer *, int > > &layers )
393403
{
394404
QList<QgsMapLayer *> layerList;
@@ -491,7 +501,7 @@ int QgsDxfExport::writeToFile( QIODevice *d, const QString &encoding )
491501
return 1;
492502
}
493503

494-
if ( !d->isOpen() && !d->open( QIODevice::WriteOnly ) )
504+
if ( !d->isOpen() && !d->open( QIODevice::WriteOnly | QIODevice::Truncate ) )
495505
{
496506
return 2;
497507
}
@@ -3633,6 +3643,7 @@ void QgsDxfExport::writeText( const QString &layer, const QString &text, const Q
36333643
writeGroup( 1, text );
36343644
writeGroup( 50, angle );
36353645
writeGroup( 7, QStringLiteral( "STANDARD" ) ); // so far only support for standard font
3646+
writeGroup( 100, QStringLiteral( "AcDbText" ) );
36363647
}
36373648

36383649
void QgsDxfExport::writeMText( const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color )
@@ -4400,30 +4411,36 @@ void QgsDxfExport::drawLabel( const QString &layerId, QgsRenderContext &context,
44004411
}
44014412
}
44024413

4403-
txt = txt.replace( wrapchr, QLatin1String( "\\P" ) );
4404-
4405-
if ( tmpLyr.format().font().underline() )
4414+
if ( mFlags & FlagNoMText )
44064415
{
4407-
txt.prepend( "\\L" ).append( "\\l" );
4416+
writeText( dxfLayer, txt, QgsPoint( label->getX(), label->getY() ), label->getHeight(), label->getAlpha() * 180.0 / M_PI, tmpLyr.format().color() );
44084417
}
4409-
4410-
if ( tmpLyr.format().font().overline() )
4418+
else
44114419
{
4412-
txt.prepend( "\\O" ).append( "\\o" );
4413-
}
4420+
txt = txt.replace( wrapchr, QLatin1String( "\\P" ) );
44144421

4415-
if ( tmpLyr.format().font().strikeOut() )
4416-
{
4417-
txt.prepend( "\\K" ).append( "\\k" );
4418-
}
4422+
if ( tmpLyr.format().font().underline() )
4423+
{
4424+
txt.prepend( "\\L" ).append( "\\l" );
4425+
}
4426+
4427+
if ( tmpLyr.format().font().overline() )
4428+
{
4429+
txt.prepend( "\\O" ).append( "\\o" );
4430+
}
44194431

4420-
txt.prepend( QStringLiteral( "\\f%1|i%2|b%3;\\H%4;" )
4421-
.arg( tmpLyr.format().font().family() )
4422-
.arg( tmpLyr.format().font().italic() ? 1 : 0 )
4423-
.arg( tmpLyr.format().font().bold() ? 1 : 0 )
4424-
.arg( label->getHeight() / ( 1 + txt.count( QStringLiteral( "\\P" ) ) ) * 0.75 ) );
4432+
if ( tmpLyr.format().font().strikeOut() )
4433+
{
4434+
txt.prepend( "\\K" ).append( "\\k" );
4435+
}
44254436

4426-
writeMText( dxfLayer, txt, QgsPoint( label->getX(), label->getY() ), label->getWidth(), label->getAlpha() * 180.0 / M_PI, tmpLyr.format().color() );
4437+
txt.prepend( QStringLiteral( "\\f%1|i%2|b%3;\\H%4;" )
4438+
.arg( tmpLyr.format().font().family() )
4439+
.arg( tmpLyr.format().font().italic() ? 1 : 0 )
4440+
.arg( tmpLyr.format().font().bold() ? 1 : 0 )
4441+
.arg( label->getHeight() / ( 1 + txt.count( QStringLiteral( "\\P" ) ) ) * 0.75 ) );
4442+
writeMText( dxfLayer, txt, QgsPoint( label->getX(), label->getY() ), label->getWidth(), label->getAlpha() * 180.0 / M_PI, tmpLyr.format().color() );
4443+
}
44274444
}
44284445

44294446

‎src/core/dxf/qgsdxfexport.h

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ class CORE_EXPORT QgsDxfExport
5353
public:
5454
enum SymbologyExport
5555
{
56-
NoSymbology = 0, //export only data
57-
FeatureSymbology, //Keeps the number of features and export symbology per feature (using the first symbol level)
58-
SymbolLayerSymbology //Exports one feature per symbol layer (considering symbol levels)
56+
NoSymbology = 0, //!< Export only data
57+
FeatureSymbology, //!< Keeps the number of features and export symbology per feature (using the first symbol level)
58+
SymbolLayerSymbology //!< Exports one feature per symbol layer (considering symbol levels)
5959
};
6060

61+
//! Export flags
62+
enum Flag
63+
{
64+
FlagNoMText = 1 << 1, //!< Export text as TEXT elements. If not set, text will be exported as MTEXT elements.
65+
};
66+
Q_DECLARE_FLAGS( Flags, Flag )
67+
6168
/**
6269
* Constructor for QgsDxfExport.
6370
*/
@@ -71,6 +78,20 @@ class CORE_EXPORT QgsDxfExport
7178
*/
7279
void setMapSettings( const QgsMapSettings &settings );
7380

81+
/**
82+
* Sets the export flags.
83+
* \since QGIS 3.0
84+
* \see flags()
85+
*/
86+
void setFlags( QgsDxfExport::Flags flags );
87+
88+
/**
89+
* Returns the export flags.
90+
* \since QGIS 3.0
91+
* \see setFlags()
92+
*/
93+
QgsDxfExport::Flags flags() const;
94+
7495
/**
7596
* Add layers to export
7697
* \param layers list of layers and corresponding attribute indexes that determine the layer name (-1 for original layer name or title)
@@ -440,6 +461,11 @@ class CORE_EXPORT QgsDxfExport
440461
QHash<QString, int> mLayerNameAttribute;
441462
double mFactor = 1.0;
442463
bool mForce2d = false;
464+
465+
QgsDxfExport::Flags mFlags = 0;
466+
443467
};
444468

469+
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDxfExport::Flags )
470+
445471
#endif // QGSDXFEXPORT_H

‎src/crashhandler/CMakeLists.txt

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
INCLUDE_DIRECTORIES(SYSTEM
2-
${CMAKE_CURRENT_BINARY_DIR}
3-
)
4-
5-
QT5_WRAP_UI(CRASH_UIS_H qgscrashdialog.ui)
6-
QT5_WRAP_CPP(CRASH_HDR_MOC qgscrashdialog.h)
7-
8-
SET(IMAGE_RCCS ../../images/images.qrc)
9-
QT5_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS})
10-
11-
# -wd4091 Avoid 'typedef' ignored on left of '' when no variable is declared warning in DbgHelp.h
12-
SET_SOURCE_FILES_PROPERTIES(qgsstacktrace.cpp PROPERTIES COMPILE_FLAGS -wd4091)
13-
14-
ADD_EXECUTABLE(qgiscrashhandler WIN32
15-
main.cpp
16-
${CRASH_UIS_H}
17-
${CRASH_HDR_MOC}
18-
${IMAGE_RCC_SRCS}
19-
qgscrashdialog.cpp
20-
qgsstacktrace.cpp
21-
qgscrashreport.cpp
22-
${CMAKE_CURRENT_SOURCE_DIR}/../app/qgis_win32.rc
23-
)
24-
25-
TARGET_LINK_LIBRARIES(qgiscrashhandler
26-
${QT_QTCORE_LIBRARY}
27-
${QT_QTGUI_LIBRARY}
28-
DbgHelp
29-
)
30-
31-
INSTALL(CODE "MESSAGE(\"Installing crashhandler ...\")")
32-
INSTALL(TARGETS qgiscrashhandler RUNTIME DESTINATION ${QGIS_LIBEXEC_DIR})
1+
INCLUDE_DIRECTORIES(SYSTEM
2+
${CMAKE_CURRENT_BINARY_DIR}
3+
)
4+
5+
QT5_WRAP_UI(CRASH_UIS_H qgscrashdialog.ui)
6+
QT5_WRAP_CPP(CRASH_HDR_MOC qgscrashdialog.h)
7+
8+
SET(IMAGE_RCCS ../../images/images.qrc)
9+
QT5_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS})
10+
11+
# -wd4091 Avoid 'typedef' ignored on left of '' when no variable is declared warning in DbgHelp.h
12+
SET_SOURCE_FILES_PROPERTIES(qgsstacktrace.cpp PROPERTIES COMPILE_FLAGS -wd4091)
13+
14+
ADD_EXECUTABLE(qgiscrashhandler WIN32
15+
main.cpp
16+
${CRASH_UIS_H}
17+
${CRASH_HDR_MOC}
18+
${IMAGE_RCC_SRCS}
19+
qgscrashdialog.cpp
20+
qgsstacktrace.cpp
21+
qgscrashreport.cpp
22+
${CMAKE_CURRENT_SOURCE_DIR}/../app/qgis_win32.rc
23+
)
24+
25+
TARGET_LINK_LIBRARIES(qgiscrashhandler
26+
${QT_QTCORE_LIBRARY}
27+
${QT_QTGUI_LIBRARY}
28+
DbgHelp
29+
)
30+
31+
INSTALL(CODE "MESSAGE(\"Installing crashhandler ...\")")
32+
INSTALL(TARGETS qgiscrashhandler RUNTIME DESTINATION ${QGIS_LIBEXEC_DIR})

‎src/crashhandler/qgscrashdialog.h

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
/***************************************************************************
2-
qgscrashdialog.h - QgsCrashDialog
3-
4-
---------------------
5-
begin : 11.4.2017
6-
copyright : (C) 2017 by Nathan Woodrow
7-
email : woodrow.nathan@gmail.com
8-
***************************************************************************
9-
* *
10-
* This program is free software; you can redistribute it and/or modify *
11-
* it under the terms of the GNU General Public License as published by *
12-
* the Free Software Foundation; either version 2 of the License, or *
13-
* (at your option) any later version. *
14-
* *
15-
***************************************************************************/
16-
17-
#ifndef QGSCRASHDIALOG_H
18-
#define QGSCRASHDIALOG_H
19-
20-
#include <QDialog>
21-
#include <QFormLayout>
22-
#include <QPlainTextEdit>
23-
#include <QPushButton>
24-
25-
#include "ui_qgscrashdialog.h"
26-
27-
/**
28-
* A dialog to show a nicer crash dialog to the user.
29-
*/
30-
class QgsCrashDialog : public QDialog, private Ui::QgsCrashDialog
31-
{
32-
Q_OBJECT
33-
public:
34-
35-
/**
36-
* A dialog to show a nicer crash dialog to the user.
37-
*/
38-
QgsCrashDialog( QWidget *parent = nullptr );
39-
40-
void setBugReport( const QString &reportData );
41-
void setReloadArgs( const QString &reloadArgs );
42-
43-
static QString htmlToMarkdown( const QString &html );
44-
45-
private slots:
46-
void showReportWidget();
47-
void createBugReport();
48-
void reloadQGIS();
49-
50-
private:
51-
QString mReportData;
52-
QString mReloadArgs;
53-
};
54-
55-
#endif // QGSCRASHDIALOG_H
1+
/***************************************************************************
2+
qgscrashdialog.h - QgsCrashDialog
3+
4+
---------------------
5+
begin : 11.4.2017
6+
copyright : (C) 2017 by Nathan Woodrow
7+
email : woodrow.nathan@gmail.com
8+
***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
17+
#ifndef QGSCRASHDIALOG_H
18+
#define QGSCRASHDIALOG_H
19+
20+
#include <QDialog>
21+
#include <QFormLayout>
22+
#include <QPlainTextEdit>
23+
#include <QPushButton>
24+
25+
#include "ui_qgscrashdialog.h"
26+
27+
/**
28+
* A dialog to show a nicer crash dialog to the user.
29+
*/
30+
class QgsCrashDialog : public QDialog, private Ui::QgsCrashDialog
31+
{
32+
Q_OBJECT
33+
public:
34+
35+
/**
36+
* A dialog to show a nicer crash dialog to the user.
37+
*/
38+
QgsCrashDialog( QWidget *parent = nullptr );
39+
40+
void setBugReport( const QString &reportData );
41+
void setReloadArgs( const QString &reloadArgs );
42+
43+
static QString htmlToMarkdown( const QString &html );
44+
45+
private slots:
46+
void showReportWidget();
47+
void createBugReport();
48+
void reloadQGIS();
49+
50+
private:
51+
QString mReportData;
52+
QString mReloadArgs;
53+
};
54+
55+
#endif // QGSCRASHDIALOG_H

‎src/crashhandler/qgscrashreport.h

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
1-
/***************************************************************************
2-
qgscrashreport.h - QgsCrashReport
3-
4-
---------------------
5-
begin : 16.4.2017
6-
copyright : (C) 2017 by Nathan Woodrow
7-
email : woodrow.nathan@gmail.com
8-
***************************************************************************
9-
* *
10-
* This program is free software; you can redistribute it and/or modify *
11-
* it under the terms of the GNU General Public License as published by *
12-
* the Free Software Foundation; either version 2 of the License, or *
13-
* (at your option) any later version. *
14-
* *
15-
***************************************************************************/
16-
#ifndef QGSCRASHREPORT_H
17-
#define QGSCRASHREPORT_H
18-
19-
#include "qgsstacktrace.h"
20-
21-
#include <QObject>
22-
#include <QVector>
23-
24-
25-
/**
26-
* Include information to generate user friendly crash report for QGIS.
27-
*/
28-
class QgsCrashReport
29-
{
30-
public:
31-
32-
/**
33-
* Include information to generate user friendly crash report for QGIS.
34-
*/
35-
QgsCrashReport();
36-
37-
public:
38-
enum Flag
39-
{
40-
Stack = 1 << 0,
41-
Plugins = 1 << 1,
42-
ProjectDetails = 1 << 2,
43-
SystemInfo = 1 << 3,
44-
QgisInfo = 1 << 4,
45-
All = Stack | Plugins | ProjectDetails | SystemInfo | QgisInfo
46-
};
47-
Q_DECLARE_FLAGS( Flags, Flag )
48-
49-
/**
50-
* Sets the stack trace for the crash report.
51-
* \param value A string list for each line in the stack trace.
52-
*/
53-
void setStackTrace( QgsStackTrace *value ) { mStackTrace = value; }
54-
55-
/**
56-
* Returns the stack trace for this report.
57-
* \return A string list for each line in the stack trace.
58-
*/
59-
QgsStackTrace *StackTrace() const { return mStackTrace; }
60-
61-
/**
62-
* Set the flags to mark which features are included in this crash report.
63-
* \param flags The flag for each feature.
64-
*/
65-
void setFlags( QgsCrashReport::Flags flags );
66-
67-
/**
68-
* Returns the include flags that have been set for this report.
69-
* \return The flags marking what details are included in this report.
70-
*/
71-
Flags flags() const { return mFlags; }
72-
73-
const QString toMarkdown();
74-
75-
/**
76-
* Generate a string version of the report.
77-
* \return A formatted string including all the information from the report.
78-
*/
79-
const QString toHtml() const;
80-
81-
/**
82-
* Generates a crash ID for the crash report.
83-
* \return
84-
*/
85-
const QString crashID() const;
86-
87-
void exportToCrashFolder();
88-
89-
QString crashReportFolder();
90-
91-
void setVersionInfo( const QStringList &versionInfo ) { mVersionInfo = versionInfo; }
92-
93-
private:
94-
Flags mFlags;
95-
QgsStackTrace *mStackTrace;
96-
QStringList mVersionInfo;
97-
};
98-
99-
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsCrashReport::Flags )
100-
101-
#endif // QGSCRASHREPORT_H
1+
/***************************************************************************
2+
qgscrashreport.h - QgsCrashReport
3+
4+
---------------------
5+
begin : 16.4.2017
6+
copyright : (C) 2017 by Nathan Woodrow
7+
email : woodrow.nathan@gmail.com
8+
***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
#ifndef QGSCRASHREPORT_H
17+
#define QGSCRASHREPORT_H
18+
19+
#include "qgsstacktrace.h"
20+
21+
#include <QObject>
22+
#include <QVector>
23+
24+
25+
/**
26+
* Include information to generate user friendly crash report for QGIS.
27+
*/
28+
class QgsCrashReport
29+
{
30+
public:
31+
32+
/**
33+
* Include information to generate user friendly crash report for QGIS.
34+
*/
35+
QgsCrashReport();
36+
37+
public:
38+
enum Flag
39+
{
40+
Stack = 1 << 0,
41+
Plugins = 1 << 1,
42+
ProjectDetails = 1 << 2,
43+
SystemInfo = 1 << 3,
44+
QgisInfo = 1 << 4,
45+
All = Stack | Plugins | ProjectDetails | SystemInfo | QgisInfo
46+
};
47+
Q_DECLARE_FLAGS( Flags, Flag )
48+
49+
/**
50+
* Sets the stack trace for the crash report.
51+
* \param value A string list for each line in the stack trace.
52+
*/
53+
void setStackTrace( QgsStackTrace *value ) { mStackTrace = value; }
54+
55+
/**
56+
* Returns the stack trace for this report.
57+
* \return A string list for each line in the stack trace.
58+
*/
59+
QgsStackTrace *StackTrace() const { return mStackTrace; }
60+
61+
/**
62+
* Set the flags to mark which features are included in this crash report.
63+
* \param flags The flag for each feature.
64+
*/
65+
void setFlags( QgsCrashReport::Flags flags );
66+
67+
/**
68+
* Returns the include flags that have been set for this report.
69+
* \return The flags marking what details are included in this report.
70+
*/
71+
Flags flags() const { return mFlags; }
72+
73+
const QString toMarkdown();
74+
75+
/**
76+
* Generate a string version of the report.
77+
* \return A formatted string including all the information from the report.
78+
*/
79+
const QString toHtml() const;
80+
81+
/**
82+
* Generates a crash ID for the crash report.
83+
* \return
84+
*/
85+
const QString crashID() const;
86+
87+
void exportToCrashFolder();
88+
89+
QString crashReportFolder();
90+
91+
void setVersionInfo( const QStringList &versionInfo ) { mVersionInfo = versionInfo; }
92+
93+
private:
94+
Flags mFlags;
95+
QgsStackTrace *mStackTrace;
96+
QStringList mVersionInfo;
97+
};
98+
99+
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsCrashReport::Flags )
100+
101+
#endif // QGSCRASHREPORT_H

‎src/ui/qgsdxfexportdialogbase.ui

100644100755
Lines changed: 94 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
<string>DXF Export</string>
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout_2">
17-
<item row="2" column="0">
18-
<widget class="QLabel" name="mSymbologyScaleLabel">
17+
<item row="1" column="0">
18+
<widget class="QLabel" name="mSymbologyModeLabel">
1919
<property name="text">
20-
<string>Symbology scale</string>
20+
<string>Symbology mode</string>
2121
</property>
2222
</widget>
2323
</item>
24-
<item row="0" column="2">
25-
<widget class="QToolButton" name="mFileSelectionButton">
24+
<item row="0" column="0">
25+
<widget class="QLabel" name="mSaveAsLabel">
2626
<property name="text">
27-
<string></string>
27+
<string>Save as</string>
2828
</property>
2929
</widget>
3030
</item>
31-
<item row="0" column="0">
32-
<widget class="QLabel" name="mSaveAsLabel">
31+
<item row="0" column="2">
32+
<widget class="QToolButton" name="mFileSelectionButton">
3333
<property name="text">
34-
<string>Save as</string>
34+
<string></string>
3535
</property>
3636
</widget>
3737
</item>
@@ -54,13 +54,16 @@
5454
</item>
5555
</widget>
5656
</item>
57-
<item row="1" column="0">
58-
<widget class="QLabel" name="mSymbologyModeLabel">
57+
<item row="2" column="0">
58+
<widget class="QLabel" name="mSymbologyScaleLabel">
5959
<property name="text">
60-
<string>Symbology mode</string>
60+
<string>Symbology scale</string>
6161
</property>
6262
</widget>
6363
</item>
64+
<item row="3" column="1" colspan="2">
65+
<widget class="QComboBox" name="mEncoding"/>
66+
</item>
6467
<item row="7" column="0" colspan="3">
6568
<widget class="QgsLayerTreeView" name="mTreeView">
6669
<property name="selectionMode">
@@ -81,8 +84,35 @@
8184
</property>
8285
</widget>
8386
</item>
84-
<item row="3" column="1" colspan="2">
85-
<widget class="QComboBox" name="mEncoding"/>
87+
<item row="5" column="1" colspan="2">
88+
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
89+
<property name="focusPolicy">
90+
<enum>Qt::StrongFocus</enum>
91+
</property>
92+
</widget>
93+
</item>
94+
<item row="4" column="1" colspan="2">
95+
<widget class="QComboBox" name="mVisibilityPresets"/>
96+
</item>
97+
<item row="15" column="0" colspan="3">
98+
<widget class="QDialogButtonBox" name="buttonBox">
99+
<property name="orientation">
100+
<enum>Qt::Horizontal</enum>
101+
</property>
102+
<property name="standardButtons">
103+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
104+
</property>
105+
</widget>
106+
</item>
107+
<item row="0" column="1">
108+
<widget class="QLineEdit" name="mFileLineEdit"/>
109+
</item>
110+
<item row="5" column="0">
111+
<widget class="QLabel" name="label_3">
112+
<property name="text">
113+
<string>CRS</string>
114+
</property>
115+
</widget>
86116
</item>
87117
<item row="9" column="0" colspan="3">
88118
<layout class="QGridLayout" name="gridLayout_3">
@@ -115,70 +145,67 @@
115145
</item>
116146
</layout>
117147
</item>
118-
<item row="0" column="1">
119-
<widget class="QLineEdit" name="mFileLineEdit"/>
120-
</item>
121-
<item row="11" column="0" colspan="3">
122-
<widget class="QCheckBox" name="mMapExtentCheckBox">
123-
<property name="text">
124-
<string>Export features intersecting the current map extent</string>
125-
</property>
126-
</widget>
127-
</item>
128-
<item row="13" column="0" colspan="3">
129-
<widget class="QDialogButtonBox" name="buttonBox">
130-
<property name="orientation">
131-
<enum>Qt::Horizontal</enum>
132-
</property>
133-
<property name="standardButtons">
134-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
135-
</property>
136-
</widget>
137-
</item>
138-
<item row="4" column="1" colspan="2">
139-
<widget class="QComboBox" name="mVisibilityPresets"/>
140-
</item>
141-
<item row="4" column="0">
142-
<widget class="QLabel" name="mSymbologyScaleLabel_2">
143-
<property name="text">
144-
<string>Map themes</string>
145-
</property>
146-
</widget>
147-
</item>
148148
<item row="3" column="0">
149149
<widget class="QLabel" name="label">
150150
<property name="text">
151151
<string>Encoding</string>
152152
</property>
153153
</widget>
154154
</item>
155-
<item row="10" column="0" colspan="3">
156-
<widget class="QCheckBox" name="mLayerTitleAsName">
157-
<property name="text">
158-
<string>Use layer title as name if set</string>
159-
</property>
160-
</widget>
161-
</item>
162-
<item row="5" column="0">
163-
<widget class="QLabel" name="label_3">
155+
<item row="4" column="0">
156+
<widget class="QLabel" name="mSymbologyScaleLabel_2">
164157
<property name="text">
165-
<string>CRS</string>
166-
</property>
167-
</widget>
168-
</item>
169-
<item row="5" column="1" colspan="2">
170-
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
171-
<property name="focusPolicy">
172-
<enum>Qt::StrongFocus</enum>
158+
<string>Map themes</string>
173159
</property>
174160
</widget>
175161
</item>
176-
<item row="12" column="0" colspan="3">
177-
<widget class="QCheckBox" name="mForce2d">
178-
<property name="text">
179-
<string>Force 2d output (eg. to support polyline width)</string>
180-
</property>
181-
</widget>
162+
<item row="11" column="0" colspan="3">
163+
<layout class="QGridLayout" name="gridLayout">
164+
<item row="1" column="0">
165+
<widget class="QCheckBox" name="mMapExtentCheckBox">
166+
<property name="text">
167+
<string>Export features intersecting the current map extent</string>
168+
</property>
169+
</widget>
170+
</item>
171+
<item row="0" column="0">
172+
<widget class="QCheckBox" name="mLayerTitleAsName">
173+
<property name="text">
174+
<string>Use layer title as name if set</string>
175+
</property>
176+
</widget>
177+
</item>
178+
<item row="2" column="0">
179+
<widget class="QCheckBox" name="mForce2d">
180+
<property name="text">
181+
<string>Force 2d output (eg. to support polyline width)</string>
182+
</property>
183+
</widget>
184+
</item>
185+
<item row="0" column="1">
186+
<widget class="QCheckBox" name="mMTextCheckBox">
187+
<property name="text">
188+
<string>Export labels as MTEXT elements</string>
189+
</property>
190+
<property name="checked">
191+
<bool>true</bool>
192+
</property>
193+
</widget>
194+
</item>
195+
<item row="0" column="2">
196+
<spacer name="horizontalSpacer_2">
197+
<property name="orientation">
198+
<enum>Qt::Horizontal</enum>
199+
</property>
200+
<property name="sizeHint" stdset="0">
201+
<size>
202+
<width>40</width>
203+
<height>20</height>
204+
</size>
205+
</property>
206+
</spacer>
207+
</item>
208+
</layout>
182209
</item>
183210
</layout>
184211
</widget>
@@ -211,9 +238,6 @@
211238
<tabstop>mTreeView</tabstop>
212239
<tabstop>mSelectAllButton</tabstop>
213240
<tabstop>mDeselectAllButton</tabstop>
214-
<tabstop>mLayerTitleAsName</tabstop>
215-
<tabstop>mMapExtentCheckBox</tabstop>
216-
<tabstop>mForce2d</tabstop>
217241
<tabstop>buttonBox</tabstop>
218242
</tabstops>
219243
<resources/>

‎tests/src/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
1111
${CMAKE_SOURCE_DIR}/src/annotations
1212
${CMAKE_SOURCE_DIR}/src/core/auth
1313
${CMAKE_SOURCE_DIR}/src/core/composer
14+
${CMAKE_SOURCE_DIR}/src/core/dxf
1415
${CMAKE_SOURCE_DIR}/src/core/expression
1516
${CMAKE_SOURCE_DIR}/src/core/geometry
1617
${CMAKE_SOURCE_DIR}/src/core/layout
@@ -109,6 +110,7 @@ SET(TESTS
109110
testqgsdatasourceuri.cpp
110111
testqgsdiagram.cpp
111112
testqgsdistancearea.cpp
113+
testqgsdxfexport.cpp
112114
testqgsellipsemarker.cpp
113115
testqgsexpressioncontext.cpp
114116
testqgsexpression.cpp

‎tests/src/core/testqgsdxfexport.cpp

Lines changed: 335 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,335 @@
1+
/***************************************************************************
2+
testqgsdxfexport.cpp
3+
--------------------
4+
Date : November 2017
5+
Copyright : (C) 2017 by Nyall Dawson
6+
Email : nyall dot dawson at gmail dot com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#include "qgstest.h"
17+
18+
#include "qgsapplication.h"
19+
#include "qgsdxfexport.h"
20+
#include "qgsproject.h"
21+
#include "qgsvectorlayer.h"
22+
#include "qgsfontutils.h"
23+
#include "qgstextrenderer.h"
24+
#include "qgspallabeling.h"
25+
#include "qgslabelingengine.h"
26+
#include "qgsvectorlayerlabeling.h"
27+
#include <QTemporaryFile>
28+
29+
class TestQgsDxfExport : public QObject
30+
{
31+
Q_OBJECT
32+
public:
33+
TestQgsDxfExport() = default;
34+
35+
private slots:
36+
void initTestCase();
37+
void cleanupTestCase();
38+
void init();// will be called before each testfunction is executed.
39+
void cleanup();// will be called after every testfunction.
40+
void testPoints();
41+
void testLines();
42+
void testPolygons();
43+
void testMtext();
44+
void testText();
45+
46+
private:
47+
QgsVectorLayer *mPointLayer = nullptr;
48+
QgsVectorLayer *mLineLayer = nullptr;
49+
QgsVectorLayer *mPolygonLayer = nullptr;
50+
51+
QString mReport;
52+
53+
void setDefaultLabelParams( QgsPalLayerSettings &settings );
54+
QString getTempFileName( const QString &file ) const;
55+
56+
bool fileContainsText( const QString &path, const QString &text ) const;
57+
};
58+
59+
void TestQgsDxfExport::initTestCase()
60+
{
61+
QgsApplication::init();
62+
QgsApplication::initQgis();
63+
QgsApplication::showSettings();
64+
QgsFontUtils::loadStandardTestFonts( QStringList() << QStringLiteral( "Bold" ) );
65+
}
66+
67+
void TestQgsDxfExport::cleanupTestCase()
68+
{
69+
QgsApplication::exitQgis();
70+
}
71+
72+
void TestQgsDxfExport::init()
73+
{
74+
QString filename = QStringLiteral( TEST_DATA_DIR ) + "/points.shp";
75+
mPointLayer = new QgsVectorLayer( filename, QStringLiteral( "points" ), QStringLiteral( "ogr" ) );
76+
Q_ASSERT( mPointLayer->isValid() );
77+
QgsProject::instance()->addMapLayer( mPointLayer );
78+
filename = QStringLiteral( TEST_DATA_DIR ) + "/lines.shp";
79+
mLineLayer = new QgsVectorLayer( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) );
80+
Q_ASSERT( mLineLayer->isValid() );
81+
QgsProject::instance()->addMapLayer( mLineLayer );
82+
filename = QStringLiteral( TEST_DATA_DIR ) + "/polys.shp";
83+
mPolygonLayer = new QgsVectorLayer( filename, QStringLiteral( "polygons" ), QStringLiteral( "ogr" ) );
84+
Q_ASSERT( mPolygonLayer->isValid() );
85+
QgsProject::instance()->addMapLayer( mPolygonLayer );
86+
}
87+
88+
void TestQgsDxfExport::cleanup()
89+
{
90+
QgsProject::instance()->removeMapLayer( mPointLayer->id() );
91+
mPointLayer = nullptr;
92+
}
93+
94+
void TestQgsDxfExport::testPoints()
95+
{
96+
QgsDxfExport d;
97+
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mPointLayer, -1 ) );
98+
99+
QgsMapSettings mapSettings;
100+
QSize size( 640, 480 );
101+
mapSettings.setOutputSize( size );
102+
mapSettings.setExtent( mPointLayer->extent() );
103+
mapSettings.setLayers( QList<QgsMapLayer *>() << mPointLayer );
104+
mapSettings.setOutputDpi( 96 );
105+
mapSettings.setDestinationCrs( mPointLayer->crs() );
106+
107+
d.setMapSettings( mapSettings );
108+
d.setSymbologyScale( 1000 );
109+
110+
QString file = getTempFileName( "point_dxf" );
111+
QFile dxfFile( file );
112+
QCOMPARE( d.writeToFile( &dxfFile, QStringLiteral( "CP1252" ) ), 0 );
113+
dxfFile.close();
114+
115+
// reload and compare
116+
std::unique_ptr< QgsVectorLayer > result = qgis::make_unique< QgsVectorLayer >( file, "dxf" );
117+
QVERIFY( result->isValid() );
118+
QCOMPARE( result->featureCount(), mPointLayer->featureCount() );
119+
QCOMPARE( result->wkbType(), QgsWkbTypes::Point );
120+
}
121+
122+
void TestQgsDxfExport::testLines()
123+
{
124+
QgsDxfExport d;
125+
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mLineLayer, -1 ) );
126+
127+
QgsMapSettings mapSettings;
128+
QSize size( 640, 480 );
129+
mapSettings.setOutputSize( size );
130+
mapSettings.setExtent( mLineLayer->extent() );
131+
mapSettings.setLayers( QList<QgsMapLayer *>() << mLineLayer );
132+
mapSettings.setOutputDpi( 96 );
133+
mapSettings.setDestinationCrs( mLineLayer->crs() );
134+
135+
d.setMapSettings( mapSettings );
136+
d.setSymbologyScale( 1000 );
137+
138+
QString file = getTempFileName( "line_dxf" );
139+
QFile dxfFile( file );
140+
QCOMPARE( d.writeToFile( &dxfFile, QStringLiteral( "CP1252" ) ), 0 );
141+
dxfFile.close();
142+
143+
// reload and compare
144+
std::unique_ptr< QgsVectorLayer > result = qgis::make_unique< QgsVectorLayer >( file, "dxf" );
145+
QVERIFY( result->isValid() );
146+
QCOMPARE( result->featureCount(), mLineLayer->featureCount() );
147+
QCOMPARE( result->wkbType(), QgsWkbTypes::LineString );
148+
}
149+
150+
void TestQgsDxfExport::testPolygons()
151+
{
152+
QgsDxfExport d;
153+
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mPolygonLayer, -1 ) );
154+
155+
QgsMapSettings mapSettings;
156+
QSize size( 640, 480 );
157+
mapSettings.setOutputSize( size );
158+
mapSettings.setExtent( mPolygonLayer->extent() );
159+
mapSettings.setLayers( QList<QgsMapLayer *>() << mPolygonLayer );
160+
mapSettings.setOutputDpi( 96 );
161+
mapSettings.setDestinationCrs( mPolygonLayer->crs() );
162+
163+
d.setMapSettings( mapSettings );
164+
d.setSymbologyScale( 1000 );
165+
166+
QString file = getTempFileName( "polygon_dxf" );
167+
QFile dxfFile( file );
168+
QCOMPARE( d.writeToFile( &dxfFile, QStringLiteral( "CP1252" ) ), 0 );
169+
dxfFile.close();
170+
171+
// reload and compare
172+
std::unique_ptr< QgsVectorLayer > result = qgis::make_unique< QgsVectorLayer >( file, "dxf" );
173+
QVERIFY( result->isValid() );
174+
QCOMPARE( result->featureCount(), 12L );
175+
QCOMPARE( result->wkbType(), QgsWkbTypes::LineString );
176+
}
177+
178+
void TestQgsDxfExport::testMtext()
179+
{
180+
QgsPalLayerSettings settings;
181+
settings.fieldName = QStringLiteral( "Class" );
182+
QgsTextFormat format;
183+
format.setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ).family() );
184+
format.setSize( 12 );
185+
format.setNamedStyle( QStringLiteral( "Bold" ) );
186+
format.setColor( QColor( 200, 0, 200 ) );
187+
settings.setFormat( format );
188+
mPointLayer->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) );
189+
190+
QgsDxfExport d;
191+
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mPointLayer, -1 ) );
192+
193+
QgsMapSettings mapSettings;
194+
QSize size( 640, 480 );
195+
mapSettings.setOutputSize( size );
196+
mapSettings.setExtent( mPointLayer->extent() );
197+
mapSettings.setLayers( QList<QgsMapLayer *>() << mPointLayer );
198+
mapSettings.setOutputDpi( 96 );
199+
mapSettings.setDestinationCrs( mPointLayer->crs() );
200+
201+
d.setMapSettings( mapSettings );
202+
d.setSymbologyScale( 1000 );
203+
d.setSymbologyExport( QgsDxfExport::FeatureSymbology );
204+
205+
QString file = getTempFileName( "mtext_dxf" );
206+
QFile dxfFile( file );
207+
QCOMPARE( d.writeToFile( &dxfFile, QStringLiteral( "CP1252" ) ), 0 );
208+
dxfFile.close();
209+
210+
211+
QVERIFY( fileContainsText( file, "MTEXT\n"
212+
" 5\n"
213+
"dd\n"
214+
"100\n"
215+
"AcDbEntity\n"
216+
"100\n"
217+
"AcDbMText\n"
218+
" 8\n"
219+
"points\n"
220+
"420\n"
221+
"**no check**\n"
222+
" 10\n"
223+
"**no check**\n"
224+
" 20\n"
225+
"**no check**\n"
226+
" 1\n"
227+
"\\fQGIS Vera Sans|i0|b1;\\H3.81136;Biplane\n"
228+
" 50\n"
229+
"0.0\n"
230+
" 41\n"
231+
"**no check**\n"
232+
" 71\n"
233+
" 7\n"
234+
" 7\n"
235+
"STANDARD\n"
236+
" 0" ) );
237+
}
238+
239+
void TestQgsDxfExport::testText()
240+
{
241+
QgsPalLayerSettings settings;
242+
settings.fieldName = QStringLiteral( "Class" );
243+
QgsTextFormat format;
244+
format.setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ).family() );
245+
format.setSize( 12 );
246+
format.setNamedStyle( QStringLiteral( "Bold" ) );
247+
format.setColor( QColor( 200, 0, 200 ) );
248+
settings.setFormat( format );
249+
mPointLayer->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) );
250+
251+
QgsDxfExport d;
252+
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mPointLayer, -1 ) );
253+
254+
QgsMapSettings mapSettings;
255+
QSize size( 640, 480 );
256+
mapSettings.setOutputSize( size );
257+
mapSettings.setExtent( mPointLayer->extent() );
258+
mapSettings.setLayers( QList<QgsMapLayer *>() << mPointLayer );
259+
mapSettings.setOutputDpi( 96 );
260+
mapSettings.setDestinationCrs( mPointLayer->crs() );
261+
262+
d.setMapSettings( mapSettings );
263+
d.setSymbologyScale( 1000 );
264+
d.setSymbologyExport( QgsDxfExport::FeatureSymbology );
265+
d.setFlags( QgsDxfExport::FlagNoMText );
266+
267+
QString file = getTempFileName( "text_dxf" );
268+
QFile dxfFile( file );
269+
QCOMPARE( d.writeToFile( &dxfFile, QStringLiteral( "CP1252" ) ), 0 );
270+
dxfFile.close();
271+
272+
273+
QVERIFY( fileContainsText( file, "TEXT\n"
274+
" 5\n"
275+
"dd\n"
276+
"100\n"
277+
"AcDbEntity\n"
278+
"100\n"
279+
"AcDbText\n"
280+
" 8\n"
281+
"points\n"
282+
"420\n"
283+
"**no check**\n"
284+
" 10\n"
285+
"**no check**\n"
286+
" 20\n"
287+
"**no check**\n"
288+
" 40\n"
289+
"**no check**\n"
290+
" 1\n"
291+
"Biplane\n"
292+
" 50\n"
293+
"0.0\n"
294+
" 7\n"
295+
"STANDARD\n"
296+
"100\n"
297+
"AcDbText" ) );
298+
}
299+
300+
bool TestQgsDxfExport::fileContainsText( const QString &path, const QString &text ) const
301+
{
302+
QStringList searchLines = text.split( '\n' );
303+
QFile file( path );
304+
file.open( QIODevice::ReadOnly );
305+
QTextStream in( &file );
306+
QString line;
307+
do
308+
{
309+
bool found = true;
310+
for ( const QString &searchLine : searchLines )
311+
{
312+
line = in.readLine();
313+
if ( searchLine != QLatin1String( "**no check**" ) && line != searchLine )
314+
{
315+
found = false;
316+
break;
317+
}
318+
int i = 1;
319+
i++;
320+
}
321+
if ( found )
322+
return true;
323+
}
324+
while ( !line.isNull() );
325+
return false;
326+
}
327+
328+
QString TestQgsDxfExport::getTempFileName( const QString &file ) const
329+
{
330+
return QDir::tempPath() + '/' + file + ".dxf";
331+
}
332+
333+
334+
QGSTEST_MAIN( TestQgsDxfExport )
335+
#include "testqgsdxfexport.moc"

0 commit comments

Comments
 (0)
Please sign in to comment.