Skip to content

Commit 0f6421d

Browse files
committedFeb 19, 2019
dwg import: use Q_DECLARE_TR_FUNCTIONS in QgsDwgImporter
1 parent 92e7faa commit 0f6421d

File tree

2 files changed

+128
-125
lines changed

2 files changed

+128
-125
lines changed
 

‎src/app/dwg/qgsdwgimporter.cpp

Lines changed: 126 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ bool QgsDwgImporter::exec( const QString &sql, bool logError )
101101

102102
if ( logError )
103103
{
104-
LOG( QObject::tr( "SQL statement failed\nDatabase: %1\nSQL: %2\nError: %3" )
104+
LOG( tr( "SQL statement failed\nDatabase: %1\nSQL: %2\nError: %3" )
105105
.arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
106106
}
107107
return false;
@@ -127,7 +127,7 @@ OGRLayerH QgsDwgImporter::query( const QString &sql )
127127
if ( CPLGetLastErrorType() == CE_None )
128128
return layer;
129129

130-
LOG( QObject::tr( "SQL statement failed\nDatabase: %1\nSQL: %2\nError: %3" )
130+
LOG( tr( "SQL statement failed\nDatabase: %1\nSQL: %2\nError: %3" )
131131
.arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
132132

133133
OGR_DS_ReleaseResultSet( mDs.get(), layer );
@@ -142,7 +142,7 @@ void QgsDwgImporter::startTransaction()
142142
mInTransaction = GDALDatasetStartTransaction( mDs.get(), 0 ) == OGRERR_NONE;
143143
if ( !mInTransaction )
144144
{
145-
LOG( QObject::tr( "Could not start transaction\nDatabase: %1\nError: %2" )
145+
LOG( tr( "Could not start transaction\nDatabase: %1\nError: %2" )
146146
.arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
147147
}
148148
}
@@ -153,7 +153,7 @@ void QgsDwgImporter::commitTransaction()
153153

154154
if ( mInTransaction && GDALDatasetCommitTransaction( mDs.get() ) != OGRERR_NONE )
155155
{
156-
LOG( QObject::tr( "Could not commit transaction\nDatabase: %1\nError: %2" )
156+
LOG( tr( "Could not commit transaction\nDatabase: %1\nError: %2" )
157157
.arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
158158
}
159159
mInTransaction = false;
@@ -190,7 +190,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
190190
QFileInfo fi( drawing );
191191
if ( !fi.isReadable() )
192192
{
193-
error = QObject::tr( "Drawing %1 is unreadable" ).arg( drawing );
193+
error = tr( "Drawing %1 is unreadable" ).arg( drawing );
194194
return false;
195195
}
196196

@@ -199,15 +199,15 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
199199
mDs.reset( OGROpen( mDatabase.toUtf8().constData(), true, nullptr ) );
200200
if ( !mDs )
201201
{
202-
LOG( QObject::tr( "Could not open database [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
202+
LOG( tr( "Could not open database [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
203203
return false;
204204
}
205205

206206
// Check whether database is uptodate
207207
OGRLayerH layer = OGR_DS_GetLayerByName( mDs.get(), "drawing" );
208208
if ( !layer )
209209
{
210-
LOG( QObject::tr( "Query for drawing %1 failed." ).arg( drawing ) );
210+
LOG( tr( "Query for drawing %1 failed." ).arg( drawing ) );
211211
mDs.reset();
212212
return false;
213213
}
@@ -221,26 +221,25 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
221221
gdal::ogr_feature_unique_ptr f( OGR_L_GetNextFeature( layer ) );
222222
if ( !f )
223223
{
224-
LOG( QObject::tr( "Could not retrieve drawing name from database [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
224+
LOG( tr( "Could not retrieve drawing name from database [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
225225
mDs.reset();
226226
return false;
227227
}
228228

229229
int year, month, day, hour, minute, second, tzf;
230230
if ( !OGR_F_GetFieldAsDateTime( f.get(), lastmodifiedIdx, &year, &month, &day, &hour, &minute, &second, &tzf ) )
231231
{
232-
LOG( QObject::tr( "Recorded last modification date unreadable [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
232+
LOG( tr( "Recorded last modification date unreadable [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
233233
mDs.reset();
234234
return false;
235235
}
236236

237-
238237
#if 0
239238
QDateTime lastModified( QDate( year, month, day ), QTime( hour, minute, second ) );
240239
QString path = QString::fromUtf8( OGR_F_GetFieldAsString( f, pathIdx ) );
241240
if ( path == fi.canonicalPath() && fi.lastModified() <= lastModified )
242241
{
243-
LOG( QObject::tr( "Drawing already uptodate in database." ) );
242+
LOG( tr( "Drawing already uptodate in database." ) );
244243
OGR_F_Destroy( f );
245244
return true;
246245
}
@@ -294,23 +293,23 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
294293

295294

296295
QList<table> tables = QList<table>()
297-
<< table( QStringLiteral( "drawing" ), QObject::tr( "Imported drawings" ), wkbNone, QList<field>()
296+
<< table( QStringLiteral( "drawing" ), tr( "Imported drawings" ), wkbNone, QList<field>()
298297
<< field( QStringLiteral( "path" ), OFTString )
299298
<< field( QStringLiteral( "comments" ), OFTString )
300299
<< field( QStringLiteral( "importdat" ), OFTDateTime )
301300
<< field( QStringLiteral( "lastmodified" ), OFTDateTime )
302301
<< field( QStringLiteral( "crs" ), OFTInteger )
303302
)
304-
<< table( QStringLiteral( "headers" ), QObject::tr( "Headers" ), wkbNone, QList<field>()
303+
<< table( QStringLiteral( "headers" ), tr( "Headers" ), wkbNone, QList<field>()
305304
<< field( QStringLiteral( "k" ), OFTString )
306305
<< field( QStringLiteral( "v" ), OFTString )
307306
)
308-
<< table( QStringLiteral( "linetypes" ), QObject::tr( "Line types" ), wkbNone, QList<field>()
307+
<< table( QStringLiteral( "linetypes" ), tr( "Line types" ), wkbNone, QList<field>()
309308
<< field( QStringLiteral( "name" ), OFTString )
310309
<< field( QStringLiteral( "desc" ), OFTString )
311310
<< field( QStringLiteral( "path" ), OFTRealList )
312311
)
313-
<< table( QStringLiteral( "layers" ), QObject::tr( "Layer list" ), wkbNone, QList<field>()
312+
<< table( QStringLiteral( "layers" ), tr( "Layer list" ), wkbNone, QList<field>()
314313
<< field( QStringLiteral( "name" ), OFTString )
315314
<< field( QStringLiteral( "linetype" ), OFTString )
316315
<< field( QStringLiteral( "color" ), OFTString )
@@ -321,7 +320,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
321320
<< field( QStringLiteral( "linewidth" ), OFTReal )
322321
<< field( QStringLiteral( "flags" ), OFTInteger )
323322
)
324-
<< table( QStringLiteral( "dimstyles" ), QObject::tr( "Dimension styles" ), wkbNone, QList<field>()
323+
<< table( QStringLiteral( "dimstyles" ), tr( "Dimension styles" ), wkbNone, QList<field>()
325324
<< field( QStringLiteral( "name" ), OFTString )
326325
<< field( QStringLiteral( "dimpost" ), OFTString )
327326
<< field( QStringLiteral( "dimapost" ), OFTString )
@@ -392,7 +391,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
392391
<< field( QStringLiteral( "dimlwd" ), OFTInteger )
393392
<< field( QStringLiteral( "dimlwe" ), OFTInteger )
394393
)
395-
<< table( QStringLiteral( "textstyles" ), QObject::tr( "Text styles" ), wkbNone, QList<field>()
394+
<< table( QStringLiteral( "textstyles" ), tr( "Text styles" ), wkbNone, QList<field>()
396395
<< field( QStringLiteral( "name" ), OFTString )
397396
<< field( QStringLiteral( "height" ), OFTReal )
398397
<< field( QStringLiteral( "width" ), OFTReal )
@@ -403,36 +402,36 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
403402
<< field( QStringLiteral( "bigFont" ), OFTString )
404403
<< field( QStringLiteral( "fontFamily" ), OFTInteger )
405404
)
406-
<< table( QStringLiteral( "appdata" ), QObject::tr( "Application data" ), wkbNone, QList<field>()
405+
<< table( QStringLiteral( "appdata" ), tr( "Application data" ), wkbNone, QList<field>()
407406
<< field( QStringLiteral( "handle" ), OFTInteger )
408407
<< field( QStringLiteral( "i" ), OFTInteger )
409408
<< field( QStringLiteral( "value" ), OFTString )
410409
)
411-
<< table( QStringLiteral( "blocks" ), QObject::tr( "BLOCK entities" ), wkbPoint25D, QList<field>()
410+
<< table( QStringLiteral( "blocks" ), tr( "BLOCK entities" ), wkbPoint25D, QList<field>()
412411
ENTITY_ATTRIBUTES
413412
<< field( QStringLiteral( "thickness" ), OFTReal )
414413
<< field( QStringLiteral( "ext" ), OFTRealList )
415414
<< field( QStringLiteral( "name" ), OFTString )
416415
<< field( QStringLiteral( "flags" ), OFTInteger )
417416
)
418-
<< table( QStringLiteral( "points" ), QObject::tr( "POINT entities" ), wkbPoint25D, QList<field>()
417+
<< table( QStringLiteral( "points" ), tr( "POINT entities" ), wkbPoint25D, QList<field>()
419418
ENTITY_ATTRIBUTES
420419
<< field( QStringLiteral( "thickness" ), OFTReal )
421420
<< field( QStringLiteral( "ext" ), OFTRealList )
422421
)
423-
<< table( QStringLiteral( "lines" ), QObject::tr( "LINE entities" ), lineGeomType, QList<field>()
422+
<< table( QStringLiteral( "lines" ), tr( "LINE entities" ), lineGeomType, QList<field>()
424423
ENTITY_ATTRIBUTES
425424
<< field( QStringLiteral( "thickness" ), OFTReal )
426425
<< field( QStringLiteral( "ext" ), OFTRealList )
427426
<< field( QStringLiteral( "width" ), OFTReal )
428427
)
429-
<< table( QStringLiteral( "polylines" ), QObject::tr( "POLYLINE entities" ), lineGeomType, QList<field>()
428+
<< table( QStringLiteral( "polylines" ), tr( "POLYLINE entities" ), lineGeomType, QList<field>()
430429
ENTITY_ATTRIBUTES
431430
<< field( QStringLiteral( "width" ), OFTReal )
432431
<< field( QStringLiteral( "thickness" ), OFTReal )
433432
<< field( QStringLiteral( "ext" ), OFTRealList )
434433
)
435-
<< table( QStringLiteral( "texts" ), QObject::tr( "TEXT entities" ), wkbPoint25D, QList<field>()
434+
<< table( QStringLiteral( "texts" ), tr( "TEXT entities" ), wkbPoint25D, QList<field>()
436435
ENTITY_ATTRIBUTES
437436
<< field( QStringLiteral( "thickness" ), OFTReal )
438437
<< field( QStringLiteral( "ext" ), OFTRealList )
@@ -447,7 +446,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
447446
<< field( QStringLiteral( "alignv" ), OFTInteger )
448447
<< field( QStringLiteral( "interlin" ), OFTReal )
449448
)
450-
<< table( QStringLiteral( "hatches" ), QObject::tr( "HATCH entities" ), hatchGeomType, QList<field>()
449+
<< table( QStringLiteral( "hatches" ), tr( "HATCH entities" ), hatchGeomType, QList<field>()
451450
ENTITY_ATTRIBUTES
452451
<< field( QStringLiteral( "thickness" ), OFTReal )
453452
<< field( QStringLiteral( "ext" ), OFTRealList )
@@ -461,7 +460,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
461460
<< field( QStringLiteral( "scale" ), OFTReal )
462461
<< field( QStringLiteral( "deflines" ), OFTInteger )
463462
)
464-
<< table( QStringLiteral( "inserts" ), QObject::tr( "INSERT entities" ), wkbPoint25D, QList<field>()
463+
<< table( QStringLiteral( "inserts" ), tr( "INSERT entities" ), wkbPoint25D, QList<field>()
465464
ENTITY_ATTRIBUTES
466465
<< field( QStringLiteral( "thickness" ), OFTReal )
467466
<< field( QStringLiteral( "ext" ), OFTRealList )
@@ -480,15 +479,15 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
480479
OGRSFDriverH driver = OGRGetDriverByName( "GPKG" );
481480
if ( !driver )
482481
{
483-
LOG( QObject::tr( "Could not load geopackage driver" ) );
482+
LOG( tr( "Could not load geopackage driver" ) );
484483
return false;
485484
}
486485

487486
// create database
488487
mDs.reset( OGR_Dr_CreateDataSource( driver, mDatabase.toUtf8().constData(), nullptr ) );
489488
if ( !mDs )
490489
{
491-
LOG( QObject::tr( "Creation of datasource failed [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
490+
LOG( tr( "Creation of datasource failed [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
492491
return false;
493492
}
494493

@@ -511,7 +510,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
511510

512511
if ( !layer )
513512
{
514-
LOG( QObject::tr( "Creation of drawing layer %1 failed [%2]" ).arg( t.mName, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
513+
LOG( tr( "Creation of drawing layer %1 failed [%2]" ).arg( t.mName, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
515514
mDs.reset();
516515
return false;
517516
}
@@ -521,7 +520,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
521520
gdal::ogr_field_def_unique_ptr fld( OGR_Fld_Create( f.mName.toUtf8().constData(), f.mOgrType ) );
522521
if ( !fld )
523522
{
524-
LOG( QObject::tr( "Creation of field definition for %1.%2 failed [%3]" ).arg( t.mName, f.mName, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
523+
LOG( tr( "Creation of field definition for %1.%2 failed [%3]" ).arg( t.mName, f.mName, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
525524
mDs.reset();
526525
return false;
527526
}
@@ -535,7 +534,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
535534

536535
if ( res != OGRERR_NONE )
537536
{
538-
LOG( QObject::tr( "Creation of field %1.%2 failed [%3]" ).arg( t.mName, f.mName, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
537+
LOG( tr( "Creation of field %1.%2 failed [%3]" ).arg( t.mName, f.mName, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
539538
mDs.reset();
540539
return false;
541540
}
@@ -584,11 +583,11 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
584583

585584
if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE )
586585
{
587-
LOG( QObject::tr( "Could not update drawing record [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
586+
LOG( tr( "Could not update drawing record [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
588587
return false;
589588
}
590589

591-
LOG( QObject::tr( "Updating database from %1 [%2]." ).arg( drawing, fi.lastModified().toString() ) );
590+
LOG( tr( "Updating database from %1 [%2]." ).arg( drawing, fi.lastModified().toString() ) );
592591

593592
DRW::error result( DRW::BAD_NONE );
594593

@@ -612,51 +611,51 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
612611
}
613612
else
614613
{
615-
LOG( QObject::tr( "File %1 is not a DWG/DXF file" ).arg( drawing ) );
614+
LOG( tr( "File %1 is not a DWG/DXF file" ).arg( drawing ) );
616615
return false;
617616
}
618617

619618
switch ( result )
620619
{
621620
case DRW::BAD_NONE:
622-
error = QObject::tr( "No error." );
621+
error = tr( "No error." );
623622
break;
624623
case DRW::BAD_UNKNOWN:
625-
error = QObject::tr( "Unknown error." );
624+
error = tr( "Unknown error." );
626625
break;
627626
case DRW::BAD_OPEN:
628-
error = QObject::tr( "error opening file." );
627+
error = tr( "error opening file." );
629628
break;
630629
case DRW::BAD_VERSION:
631-
error = QObject::tr( "unsupported version." );
630+
error = tr( "unsupported version." );
632631
break;
633632
case DRW::BAD_READ_METADATA:
634-
error = QObject::tr( "error reading metadata." );
633+
error = tr( "error reading metadata." );
635634
break;
636635
case DRW::BAD_READ_FILE_HEADER:
637-
error = QObject::tr( "error in file header read process." );
636+
error = tr( "error in file header read process." );
638637
break;
639638
case DRW::BAD_READ_HEADER:
640-
error = QObject::tr( "error in header vars read process." );
639+
error = tr( "error in header vars read process." );
641640
break;
642641
case DRW::BAD_READ_HANDLES:
643-
error = QObject::tr( "error in object map read process." );
642+
error = tr( "error in object map read process." );
644643
break;
645644
case DRW::BAD_READ_CLASSES:
646-
error = QObject::tr( "error in classes read process." );
645+
error = tr( "error in classes read process." );
647646
break;
648647
case DRW::BAD_READ_TABLES:
649-
error = QObject::tr( "error in tables read process." );
648+
error = tr( "error in tables read process." );
650649
result = DRW::BAD_NONE;
651650
break;
652651
case DRW::BAD_READ_BLOCKS:
653-
error = QObject::tr( "error in block read process." );
652+
error = tr( "error in block read process." );
654653
break;
655654
case DRW::BAD_READ_ENTITIES:
656-
error = QObject::tr( "error in entities read process." );
655+
error = tr( "error in entities read process." );
657656
break;
658657
case DRW::BAD_READ_OBJECTS:
659-
error = QObject::tr( "error in objects read process." );
658+
error = tr( "error in objects read process." );
660659
break;
661660
}
662661

@@ -689,7 +688,7 @@ void QgsDwgImporter::addHeader( const DRW_Header *data )
689688

690689
if ( OGR_L_SetFeature( layer, f.get() ) != OGRERR_NONE )
691690
{
692-
LOG( QObject::tr( "Could not update comment in drawing record [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
691+
LOG( tr( "Could not update comment in drawing record [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
693692
return;
694693
}
695694
}
@@ -743,10 +742,10 @@ void QgsDwgImporter::addHeader( const DRW_Header *data )
743742

744743
if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE )
745744
{
746-
LOG( QObject::tr( "Could not add %3 %1 [%2]" )
745+
LOG( tr( "Could not add %3 %1 [%2]" )
747746
.arg( k,
748747
QString::fromUtf8( CPLGetLastErrorMsg() ),
749-
QObject::tr( "header record" ) )
748+
tr( "header record" ) )
750749
);
751750
}
752751
}
@@ -778,7 +777,7 @@ void QgsDwgImporter::addLType( const DRW_LType &data )
778777

779778
if ( path[i] == 0.0 )
780779
{
781-
NYI( QObject::tr( "dotted linetypes - dot ignored" ) );
780+
NYI( tr( "dotted linetypes - dot ignored" ) );
782781
continue;
783782
}
784783

@@ -814,10 +813,10 @@ void QgsDwgImporter::addLType( const DRW_LType &data )
814813

815814
if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE )
816815
{
817-
LOG( QObject::tr( "Could not add %3 %1 [%2]" )
816+
LOG( tr( "Could not add %3 %1 [%2]" )
818817
.arg( data.name.c_str(),
819818
QString::fromUtf8( CPLGetLastErrorMsg() ),
820-
QObject::tr( "line type" ) )
819+
tr( "line type" ) )
821820
);
822821
}
823822
}
@@ -904,8 +903,8 @@ void QgsDwgImporter::addLayer( const DRW_Layer &data )
904903

905904
if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE )
906905
{
907-
LOG( QObject::tr( "Could not add %3 %1 [%2]" )
908-
.arg( data.name.c_str(), QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "layer" ) )
906+
LOG( tr( "Could not add %3 %1 [%2]" )
907+
.arg( data.name.c_str(), QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "layer" ) )
909908
);
910909
}
911910
}
@@ -915,7 +914,7 @@ void QgsDwgImporter::setString( OGRFeatureDefnH dfn, OGRFeatureH f, const QStrin
915914
int idx = OGR_FD_GetFieldIndex( dfn, field.toLower().toUtf8().constData() );
916915
if ( idx < 0 )
917916
{
918-
LOG( QObject::tr( "Field %1 not found" ).arg( field ) );
917+
LOG( tr( "Field %1 not found" ).arg( field ) );
919918
return;
920919
}
921920
OGR_F_SetFieldString( f, idx, value.c_str() );
@@ -926,7 +925,7 @@ void QgsDwgImporter::setDouble( OGRFeatureDefnH dfn, OGRFeatureH f, const QStrin
926925
int idx = OGR_FD_GetFieldIndex( dfn, field.toLower().toUtf8().constData() );
927926
if ( idx < 0 )
928927
{
929-
LOG( QObject::tr( "Field %1 not found" ).arg( field ) );
928+
LOG( tr( "Field %1 not found" ).arg( field ) );
930929
return;
931930
}
932931
OGR_F_SetFieldDouble( f, idx, value );
@@ -937,7 +936,7 @@ void QgsDwgImporter::setInteger( OGRFeatureDefnH dfn, OGRFeatureH f, const QStri
937936
int idx = OGR_FD_GetFieldIndex( dfn, field.toLower().toUtf8().constData() );
938937
if ( idx < 0 )
939938
{
940-
LOG( QObject::tr( "Field %1 not found" ).arg( field ) );
939+
LOG( tr( "Field %1 not found" ).arg( field ) );
941940
return;
942941
}
943942
OGR_F_SetFieldInteger( f, idx, value );
@@ -953,7 +952,7 @@ void QgsDwgImporter::setPoint( OGRFeatureDefnH dfn, OGRFeatureH f, const QString
953952
int idx = OGR_FD_GetFieldIndex( dfn, field.toLower().toUtf8().constData() );
954953
if ( idx < 0 )
955954
{
956-
LOG( QObject::tr( "Field %1 not found" ).arg( field ) );
955+
LOG( tr( "Field %1 not found" ).arg( field ) );
957956
return;
958957
}
959958

@@ -1018,7 +1017,7 @@ double QgsDwgImporter::lineWidth( int lWeight, const std::string &layer ) const
10181017
return -1.0;
10191018
case 31:
10201019
default:
1021-
NYI( QObject::tr( "Line width default" ) );
1020+
NYI( tr( "Line width default" ) );
10221021
return 0.0;
10231022
}
10241023
}
@@ -1104,8 +1103,8 @@ void QgsDwgImporter::addDimStyle( const DRW_Dimstyle &data )
11041103

11051104
if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE )
11061105
{
1107-
LOG( QObject::tr( "Could not add %3 %1 [%2]" )
1108-
.arg( data.name.c_str(), QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "dimension style" ) )
1106+
LOG( tr( "Could not add %3 %1 [%2]" )
1107+
.arg( data.name.c_str(), QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "dimension style" ) )
11091108
);
11101109
}
11111110
}
@@ -1136,8 +1135,8 @@ void QgsDwgImporter::addTextStyle( const DRW_Textstyle &data )
11361135

11371136
if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE )
11381137
{
1139-
LOG( QObject::tr( "Could not add %3 %1 [%2]" )
1140-
.arg( data.name.c_str(), QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "text style" ) )
1138+
LOG( tr( "Could not add %3 %1 [%2]" )
1139+
.arg( data.name.c_str(), QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "text style" ) )
11411140
);
11421141
}
11431142
}
@@ -1166,7 +1165,9 @@ bool QgsDwgImporter::createFeature( OGRLayerH layer, OGRFeatureH f, const QgsAbs
11661165
OGRGeometryH geom;
11671166
if ( OGR_G_CreateFromWkb( ( unsigned char * ) wkb.constData(), nullptr, &geom, wkb.size() ) != OGRERR_NONE )
11681167
{
1169-
LOG( QObject::tr( "Could not create geometry [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
1168+
QgsDebugMsg( QStringLiteral( "Could not create geometry [%1][%2]" ).arg( g->asWkt() ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
1169+
LOG( tr( "Could not create geometry [%1]" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
1170+
return false;
11701171
}
11711172

11721173
OGR_F_SetGeometryDirectly( f, geom );
@@ -1197,8 +1198,8 @@ void QgsDwgImporter::addBlock( const DRW_Block &data )
11971198

11981199
if ( !createFeature( layer, f.get(), p ) )
11991200
{
1200-
LOG( QObject::tr( "Could not add %2 [%1]" )
1201-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "block" ) )
1201+
LOG( tr( "Could not add %2 [%1]" )
1202+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "block" ) )
12021203
);
12031204
}
12041205
}
@@ -1257,22 +1258,22 @@ void QgsDwgImporter::addPoint( const DRW_Point &data )
12571258
QgsPoint p( QgsWkbTypes::PointZ, data.basePoint.x, data.basePoint.y, data.basePoint.z );
12581259
if ( !createFeature( layer, f, p ) )
12591260
{
1260-
LOG( QObject::tr( "Could not add %2 [%1]" )
1261-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "point" ) )
1261+
LOG( tr( "Could not add %2 [%1]" )
1262+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) )
12621263
);
12631264
}
12641265
}
12651266

12661267
void QgsDwgImporter::addRay( const DRW_Ray &data )
12671268
{
12681269
Q_UNUSED( data );
1269-
NYI( QObject::tr( "RAY entities" ) );
1270+
NYI( tr( "RAY entities" ) );
12701271
}
12711272

12721273
void QgsDwgImporter::addXline( const DRW_Xline &data )
12731274
{
12741275
Q_UNUSED( data );
1275-
NYI( QObject::tr( "XLINE entities" ) );
1276+
NYI( tr( "XLINE entities" ) );
12761277
}
12771278

12781279
bool QgsDwgImporter::circularStringFromArc( const DRW_Arc &data, QgsCircularString &c )
@@ -1299,8 +1300,8 @@ void QgsDwgImporter::addArc( const DRW_Arc &data )
12991300
QgsCircularString c;
13001301
if ( !circularStringFromArc( data, c ) )
13011302
{
1302-
LOG( QObject::tr( "Could not create circular string from %2 [%1]" )
1303-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "arc" ) )
1303+
LOG( tr( "Could not create circular string from %2 [%1]" )
1304+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "arc" ) )
13041305
);
13051306
return;
13061307
}
@@ -1319,8 +1320,8 @@ void QgsDwgImporter::addArc( const DRW_Arc &data )
13191320

13201321
if ( !createFeature( layer, f, c ) )
13211322
{
1322-
LOG( QObject::tr( "Could not add %2 [%1]" )
1323-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "arc" ) )
1323+
LOG( tr( "Could not add %2 [%1]" )
1324+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "arc" ) )
13241325
);
13251326
}
13261327
}
@@ -1349,8 +1350,8 @@ void QgsDwgImporter::addCircle( const DRW_Circle &data )
13491350

13501351
if ( !createFeature( layer, f, c ) )
13511352
{
1352-
LOG( QObject::tr( "Could not add %2 [%1]" )
1353-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "circle" ) )
1353+
LOG( tr( "Could not add %2 [%1]" )
1354+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "circle" ) )
13541355
);
13551356
}
13561357
}
@@ -1500,8 +1501,8 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
15001501

15011502
if ( !createFeature( layer, f, cc ) )
15021503
{
1503-
LOG( QObject::tr( "Could not add %2 [%1]" )
1504-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "line string" ) )
1504+
LOG( tr( "Could not add %2 [%1]" )
1505+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) )
15051506
);
15061507
}
15071508

@@ -1571,8 +1572,8 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
15711572

15721573
if ( !createFeature( layer, f, poly ) )
15731574
{
1574-
LOG( QObject::tr( "Could not add %2 [%1]" )
1575-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "polygon" ) )
1575+
LOG( tr( "Could not add %2 [%1]" )
1576+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) )
15761577
);
15771578
}
15781579
}
@@ -1615,8 +1616,8 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
16151616

16161617
if ( !createFeature( layer, f, cc ) )
16171618
{
1618-
LOG( QObject::tr( "Could not add %2 [%1]" )
1619-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "line string" ) )
1619+
LOG( tr( "Could not add %2 [%1]" )
1620+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) )
16201621
);
16211622
}
16221623
}
@@ -1696,8 +1697,8 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
16961697

16971698
if ( !createFeature( layer, f, cc ) )
16981699
{
1699-
LOG( QObject::tr( "Could not add %2 [%1]" )
1700-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "line string" ) )
1700+
LOG( tr( "Could not add %2 [%1]" )
1701+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) )
17011702
);
17021703
}
17031704

@@ -1772,8 +1773,8 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
17721773

17731774
if ( !createFeature( layer, f, poly ) )
17741775
{
1775-
LOG( QObject::tr( "Could not add %2 [%1]" )
1776-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "polygon" ) )
1776+
LOG( tr( "Could not add %2 [%1]" )
1777+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) )
17771778
);
17781779
}
17791780
}
@@ -1816,8 +1817,8 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
18161817

18171818
if ( !createFeature( layer, f, cc ) )
18181819
{
1819-
LOG( QObject::tr( "Could not add %2 [%1]" )
1820-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "line string" ) )
1820+
LOG( tr( "Could not add %2 [%1]" )
1821+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) )
18211822
);
18221823
}
18231824
}
@@ -2054,8 +2055,8 @@ void QgsDwgImporter::addSpline( const DRW_Spline *data )
20542055
QgsLineString l;
20552056
if ( !lineFromSpline( *data, l ) )
20562057
{
2057-
LOG( QObject::tr( "Could not create line from %2 [%1]" )
2058-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "spline" ) )
2058+
LOG( tr( "Could not create line from %2 [%1]" )
2059+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "spline" ) )
20592060
);
20602061
return;
20612062
}
@@ -2071,16 +2072,16 @@ void QgsDwgImporter::addSpline( const DRW_Spline *data )
20712072

20722073
if ( !createFeature( layer, f, l ) )
20732074
{
2074-
LOG( QObject::tr( "Could not add %2 [%1]" )
2075-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "spline" ) )
2075+
LOG( tr( "Could not add %2 [%1]" )
2076+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "spline" ) )
20762077
);
20772078
}
20782079
}
20792080

20802081
void QgsDwgImporter::addKnot( const DRW_Entity &data )
20812082
{
20822083
Q_UNUSED( data );
2083-
NYI( QObject::tr( "KNOT entities" ) );
2084+
NYI( tr( "KNOT entities" ) );
20842085
}
20852086

20862087
void QgsDwgImporter::addInsert( const DRW_Insert &data )
@@ -2112,22 +2113,22 @@ void QgsDwgImporter::addInsert( const DRW_Insert &data )
21122113

21132114
if ( !createFeature( layer, f, p ) )
21142115
{
2115-
LOG( QObject::tr( "Could not add %2 [%1]" )
2116-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "point" ) )
2116+
LOG( tr( "Could not add %2 [%1]" )
2117+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) )
21172118
);
21182119
}
21192120
}
21202121

21212122
void QgsDwgImporter::addTrace( const DRW_Trace &data )
21222123
{
21232124
Q_UNUSED( data );
2124-
NYI( QObject::tr( "TRACE entities" ) );
2125+
NYI( tr( "TRACE entities" ) );
21252126
}
21262127

21272128
void QgsDwgImporter::add3dFace( const DRW_3Dface &data )
21282129
{
21292130
Q_UNUSED( data );
2130-
NYI( QObject::tr( "3DFACE entities" ) );
2131+
NYI( tr( "3DFACE entities" ) );
21312132
}
21322133

21332134
void QgsDwgImporter::addSolid( const DRW_Solid &data )
@@ -2163,8 +2164,8 @@ void QgsDwgImporter::addSolid( const DRW_Solid &data )
21632164

21642165
if ( !createFeature( layer, f, poly ) )
21652166
{
2166-
LOG( QObject::tr( "Could not add %2 [%1]" )
2167-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "polygon" ) )
2167+
LOG( tr( "Could not add %2 [%1]" )
2168+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) )
21682169
);
21692170
}
21702171
}
@@ -2198,8 +2199,8 @@ void QgsDwgImporter::addMText( const DRW_MText &data )
21982199

21992200
if ( !createFeature( layer, f, p ) )
22002201
{
2201-
LOG( QObject::tr( "Could not add %2 [%1]" )
2202-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "point" ) )
2202+
LOG( tr( "Could not add %2 [%1]" )
2203+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) )
22032204
);
22042205
}
22052206
}
@@ -2236,58 +2237,58 @@ void QgsDwgImporter::addText( const DRW_Text &data )
22362237

22372238
if ( !createFeature( layer, f, p ) )
22382239
{
2239-
LOG( QObject::tr( "Could not add %2 [%1]" )
2240-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "point" ) )
2240+
LOG( tr( "Could not add %2 [%1]" )
2241+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) )
22412242
);
22422243
}
22432244
}
22442245

22452246
void QgsDwgImporter::addDimAlign( const DRW_DimAligned *data )
22462247
{
22472248
Q_UNUSED( data );
2248-
NYI( QObject::tr( "DIMALIGN entities" ) );
2249+
NYI( tr( "DIMALIGN entities" ) );
22492250
}
22502251

22512252
void QgsDwgImporter::addDimLinear( const DRW_DimLinear *data )
22522253
{
22532254
Q_UNUSED( data );
2254-
NYI( QObject::tr( "DIMLINEAR entities" ) );
2255+
NYI( tr( "DIMLINEAR entities" ) );
22552256
}
22562257

22572258
void QgsDwgImporter::addDimRadial( const DRW_DimRadial *data )
22582259
{
22592260
Q_UNUSED( data );
2260-
NYI( QObject::tr( "DIMRADIAL entities" ) );
2261+
NYI( tr( "DIMRADIAL entities" ) );
22612262
}
22622263

22632264
void QgsDwgImporter::addDimDiametric( const DRW_DimDiametric *data )
22642265
{
22652266
Q_UNUSED( data );
2266-
NYI( QObject::tr( "DIMDIAMETRIC entities" ) );
2267+
NYI( tr( "DIMDIAMETRIC entities" ) );
22672268
}
22682269

22692270
void QgsDwgImporter::addDimAngular( const DRW_DimAngular *data )
22702271
{
22712272
Q_UNUSED( data );
2272-
NYI( QObject::tr( "DIMANGULAR entities" ) );
2273+
NYI( tr( "DIMANGULAR entities" ) );
22732274
}
22742275

22752276
void QgsDwgImporter::addDimAngular3P( const DRW_DimAngular3p *data )
22762277
{
22772278
Q_UNUSED( data );
2278-
NYI( QObject::tr( "DIMANGULAR3P entities" ) );
2279+
NYI( tr( "DIMANGULAR3P entities" ) );
22792280
}
22802281

22812282
void QgsDwgImporter::addDimOrdinate( const DRW_DimOrdinate *data )
22822283
{
22832284
Q_UNUSED( data );
2284-
NYI( QObject::tr( "DIMORDINAL entities" ) );
2285+
NYI( tr( "DIMORDINAL entities" ) );
22852286
}
22862287

22872288
void QgsDwgImporter::addLeader( const DRW_Leader *data )
22882289
{
22892290
Q_UNUSED( data );
2290-
NYI( QObject::tr( "LEADER entities" ) );
2291+
NYI( tr( "LEADER entities" ) );
22912292
}
22922293

22932294
void QgsDwgImporter::addHatch( const DRW_Hatch *pdata )
@@ -2322,7 +2323,7 @@ void QgsDwgImporter::addHatch( const DRW_Hatch *pdata )
23222323

23232324
if ( data.looplist.size() != data.loopsnum )
23242325
{
2325-
LOG( QObject::tr( "0x%1: %2 instead of %3 loops found" )
2326+
LOG( tr( "0x%1: %2 instead of %3 loops found" )
23262327
.arg( data.handle, 0, 16 )
23272328
.arg( data.looplist.size() )
23282329
.arg( data.loopsnum )
@@ -2400,8 +2401,8 @@ void QgsDwgImporter::addHatch( const DRW_Hatch *pdata )
24002401

24012402
if ( !createFeature( layer, f, p ) )
24022403
{
2403-
LOG( QObject::tr( "Could not add %2 [%1]" )
2404-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "polygon" ) )
2404+
LOG( tr( "Could not add %2 [%1]" )
2405+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) )
24052406
);
24062407
}
24072408
}
@@ -2429,34 +2430,34 @@ void QgsDwgImporter::addLine( const DRW_Line &data )
24292430

24302431
if ( !createFeature( layer, f, l ) )
24312432
{
2432-
LOG( QObject::tr( "Could not add %2 [%1]" )
2433-
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), QObject::tr( "line string" ) )
2433+
LOG( tr( "Could not add %2 [%1]" )
2434+
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) )
24342435
);
24352436
}
24362437
}
24372438

24382439
void QgsDwgImporter::addViewport( const DRW_Viewport &data )
24392440
{
24402441
Q_UNUSED( data );
2441-
NYI( QObject::tr( "VIEWPORT entities" ) );
2442+
NYI( tr( "VIEWPORT entities" ) );
24422443
}
24432444

24442445
void QgsDwgImporter::addImage( const DRW_Image *data )
24452446
{
24462447
Q_UNUSED( data );
2447-
NYI( QObject::tr( "IMAGE entities" ) );
2448+
NYI( tr( "IMAGE entities" ) );
24482449
}
24492450

24502451
void QgsDwgImporter::linkImage( const DRW_ImageDef *data )
24512452
{
24522453
Q_UNUSED( data );
2453-
NYI( QObject::tr( "image links" ) );
2454+
NYI( tr( "image links" ) );
24542455
}
24552456

24562457
void QgsDwgImporter::addComment( const char *comment )
24572458
{
24582459
Q_UNUSED( comment );
2459-
NYI( QObject::tr( "comments" ) );
2460+
NYI( tr( "comments" ) );
24602461
}
24612462

24622463
void QgsDwgImporter::writeHeader( DRW_Header & ) { }
@@ -2702,13 +2703,13 @@ bool QgsDwgImporter::expandInserts( QString &error )
27022703
{
27032704
if ( errors < 1000 )
27042705
{
2705-
QgsMessageLog::logMessage( QObject::tr( "Could not copy feature of block %2 from layer %1 [Errors: %3]" )
2706+
QgsMessageLog::logMessage( tr( "Could not copy feature of block %2 from layer %1 [Errors: %3]" )
27062707
.arg( name ).arg( handle ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ),
2707-
QObject::tr( "DWG/DXF import" ) );
2708+
tr( "DWG/DXF import" ) );
27082709
}
27092710
else if ( errors == 1000 )
27102711
{
2711-
QgsMessageLog::logMessage( QObject::tr( "Not logging more errors" ), QObject::tr( "DWG/DXF import" ) );
2712+
QgsMessageLog::logMessage( tr( "Not logging more errors" ), tr( "DWG/DXF import" ) );
27122713
}
27132714

27142715
++errors;
@@ -2726,12 +2727,12 @@ bool QgsDwgImporter::expandInserts( QString &error )
27262727

27272728
if ( errors > 0 )
27282729
{
2729-
error = QObject::tr( "%1 write errors during block expansion" ).arg( errors );
2730+
error = tr( "%1 write errors during block expansion" ).arg( errors );
27302731
return false;
27312732
}
27322733
else
27332734
{
2734-
error = QObject::tr( "%1 block insertion expanded." ).arg( i );
2735+
error = tr( "%1 block insertion expanded." ).arg( i );
27352736
return true;
27362737
}
27372738
}

‎src/app/dwg/qgsdwgimporter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class QgsQgsCoordinateReferenceSystem;
3030

3131
class QgsDwgImporter : public DRW_Interface
3232
{
33+
Q_DECLARE_TR_FUNCTIONS( QgsDwgImporter )
34+
3335
public:
3436
QgsDwgImporter( const QString &database, const QgsCoordinateReferenceSystem &crs );
3537
~QgsDwgImporter() override;

0 commit comments

Comments
 (0)
Please sign in to comment.