[QGIS Commit] r15380 - trunk/qgis/src/plugins/dxf2shp_converter

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Mar 7 11:45:27 EST 2011


Author: jef
Date: 2011-03-07 08:45:27 -0800 (Mon, 07 Mar 2011)
New Revision: 15380

Modified:
   trunk/qgis/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp
Log:
fix #1308

Modified: trunk/qgis/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp
===================================================================
--- trunk/qgis/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp	2011-03-07 15:36:54 UTC (rev 15379)
+++ trunk/qgis/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp	2011-03-07 16:45:27 UTC (rev 15380)
@@ -43,71 +43,75 @@
   QString inf = name->text();
   QString outd = dirout->text();
 
-  if ( inf.size() > 1 )
+  if ( inf.isEmpty() )
   {
-    int type = SHPT_POINT;
-    bool convtexts = convertTextCheck->checkState();
+    QMessageBox::information( this, tr( "Warning" ), tr( "Please specify a file to convert." ) );
+    return;
+  }
 
-    if ( polyline->isChecked() )
-      type = SHPT_ARC;
+  if ( outd.isEmpty() )
+  {
+    QMessageBox::information( this, tr( "Warning" ), tr( "Please specify an output file" ) );
+    return;
+  }
 
-    if ( polygon->isChecked() )
-      type = SHPT_POLYGON;
+  int type = SHPT_POINT;
+  bool convtexts = convertTextCheck->checkState();
 
-    if ( point->isChecked() )
-      type = SHPT_POINT;
+  if ( polyline->isChecked() )
+    type = SHPT_ARC;
 
-    InsertRetrClass *insertRetr = new InsertRetrClass();
+  if ( polygon->isChecked() )
+    type = SHPT_POLYGON;
 
-    DL_Dxf *dxf_inserts = new DL_Dxf();
+  if ( point->isChecked() )
+    type = SHPT_POINT;
 
-    if ( !dxf_inserts->in( inf.toStdString(), insertRetr ) )
-    {
-      // if file open failed
-      QgsDebugMsg( "Aborting: The input file could not be opened." );
-      return;
-    }
+  InsertRetrClass *insertRetr = new InsertRetrClass();
 
-    Builder *parser = new Builder(
-      outd.toStdString(),
-      type,
-      insertRetr->XVals, insertRetr->YVals,
-      insertRetr->Names,
-      insertRetr->countInserts,
-      convtexts );
+  DL_Dxf *dxf_inserts = new DL_Dxf();
 
-    QgsDebugMsg( QString( "Finished getting insertions. Count: %1" ).arg( insertRetr->countInserts ) );
+  if ( !dxf_inserts->in( inf.toStdString(), insertRetr ) )
+  {
+    // if file open failed
+    QgsDebugMsg( "Aborting: The input file could not be opened." );
+    return;
+  }
 
-    DL_Dxf *dxf_Main = new DL_Dxf();
+  Builder *parser = new Builder(
+    outd.toStdString(),
+    type,
+    insertRetr->XVals, insertRetr->YVals,
+    insertRetr->Names,
+    insertRetr->countInserts,
+    convtexts );
 
-    if ( !dxf_Main->in( inf.toStdString(), parser ) )
-    {
-      // if file open failed
-      QgsDebugMsg( "Aborting: The input file could not be opened." );
-      return;
-    }
+  QgsDebugMsg( QString( "Finished getting insertions. Count: %1" ).arg( insertRetr->countInserts ) );
 
-    delete insertRetr;
-    delete dxf_inserts;
-    delete dxf_Main;
+  DL_Dxf *dxf_Main = new DL_Dxf();
 
-    parser->print_shpObjects();
+  if ( !dxf_Main->in( inf.toStdString(), parser ) )
+  {
+    // if file open failed
+    QgsDebugMsg( "Aborting: The input file could not be opened." );
+    return;
+  }
 
-    emit createLayer( QString(( parser->outputShp() ).c_str() ), QString( "Data layer" ) );
+  delete insertRetr;
+  delete dxf_inserts;
+  delete dxf_Main;
 
-    if ( convtexts && parser->textObjectsSize() > 0 )
-    {
-      emit createLayer( QString(( parser->outputTShp() ).c_str() ), QString( "Text layer" ) );
-    }
+  parser->print_shpObjects();
 
-    delete parser;
-  }
-  else
+  emit createLayer( QString(( parser->outputShp() ).c_str() ), QString( "Data layer" ) );
+
+  if ( convtexts && parser->textObjectsSize() > 0 )
   {
-    QMessageBox::information( this, "Warning", "Please select a file to convert" );
-    return;
+    emit createLayer( QString(( parser->outputTShp() ).c_str() ), QString( "Text layer" ) );
   }
 
+  delete parser;
+
   accept();
 }
 
@@ -152,7 +156,7 @@
   QString s = QFileDialog::getOpenFileName( this,
               tr( "Choose a DXF file to open" ),
               settings.value( "/Plugin-DXF/text_path", "./" ).toString(),
-              "Files DXF (*.dxf)" );
+              tr( "Files DXF (*.dxf)" ) );
 
   name->setText( s );
 }
@@ -162,7 +166,7 @@
   QString s = QFileDialog::getSaveFileName( this,
               tr( "Choose a file name to save to" ),
               "output.shp",
-              "Shapefile (*.shp)" );
+              tr( "Shapefile (*.shp)" ) );
 
   dirout->setText( s );
 }



More information about the QGIS-commit mailing list