@@ -117,6 +117,18 @@ QgsVectorFileWriter::QgsVectorFileWriter(
117117 }
118118 else
119119 {
120+ QString longName;
121+ QString trLongName;
122+ QString glob;
123+ QString ext;
124+ if ( QgsVectorFileWriter::driverMetadata ( driverName, longName, trLongName, glob, ext ) )
125+ {
126+ if ( !vectorFileName.endsWith ( " ." + ext, Qt::CaseInsensitive ) )
127+ {
128+ vectorFileName += " ." + ext;
129+ }
130+ }
131+
120132 QFile::remove ( vectorFileName );
121133 }
122134
@@ -730,11 +742,14 @@ QMap<QString, QString> QgsVectorFileWriter::ogrDriverList()
730742 QString drvName = OGR_Dr_GetName ( drv );
731743 if ( OGR_Dr_TestCapability ( drv, " CreateDataSource" ) != 0 )
732744 {
733- QPair<QString, QString> p = nameAndGlob ( drvName );
734- if ( p.first .isEmpty () )
735- continue ;
736-
737- resultMap.insert ( p.first , drvName );
745+ QString longName;
746+ QString trLongName;
747+ QString glob;
748+ QString ext;
749+ if ( QgsVectorFileWriter::driverMetadata ( drvName, longName, trLongName, glob, ext ) && !trLongName.isEmpty () )
750+ {
751+ resultMap.insert ( trLongName, drvName );
752+ }
738753 }
739754 }
740755 }
@@ -759,119 +774,165 @@ QString QgsVectorFileWriter::fileFilterString()
759774
760775QString QgsVectorFileWriter::filterForDriver ( const QString& driverName )
761776{
762- QPair<QString, QString> p = nameAndGlob ( driverName );
763-
764- if ( p.first .isEmpty () || p.second .isEmpty () )
777+ QString longName;
778+ QString trLongName;
779+ QString glob;
780+ QString ext;
781+ if ( !QgsVectorFileWriter::driverMetadata ( driverName, longName, trLongName, glob, ext )
782+ || trLongName.isEmpty ()
783+ || glob.isEmpty ()
784+ )
765785 return " " ;
766786
767- return " [OGR] " + p. first + " (" + p. second . toLower () + " " + p. second .toUpper () + " )" ;
787+ return trLongName + " [OGR] (" + glob. toLower () + " " + glob .toUpper () + " )" ;
768788}
769789
770- QPair<QString, QString> QgsVectorFileWriter::nameAndGlob ( QString driverName )
790+ bool QgsVectorFileWriter::driverMetadata ( QString driverName, QString &longName, QString &trLongName, QString &glob, QString &ext )
771791{
772- QString longName;
773- QString glob;
774-
775792 if ( driverName.startsWith ( " AVCE00" ) )
776793 {
777794 longName = " Arc/Info ASCII Coverage" ;
795+ trLongName = QObject::tr ( " Arc/Info ASCII Coverage" );
778796 glob = " *.e00" ;
797+ ext = " e00" ;
779798 }
780799 else if ( driverName.startsWith ( " BNA" ) )
781800 {
782801 longName = " Atlas BNA" ;
802+ trLongName = QObject::tr ( " Atlas BNA" );
783803 glob = " *.bna" ;
804+ ext = " bna" ;
784805 }
785806 else if ( driverName.startsWith ( " CSV" ) )
786807 {
787808 longName = " Comma Separated Value" ;
809+ trLongName = QObject::tr ( " Comma Separated Value" );
788810 glob = " *.csv" ;
811+ ext = " *.bna" ;
789812 }
790813 else if ( driverName.startsWith ( " ESRI" ) )
791814 {
792815 longName = " ESRI Shapefile" ;
816+ trLongName = QObject::tr ( " ESRI Shapefile" );
793817 glob = " *.shp" ;
818+ ext = " shp" ;
794819 }
795820 else if ( driverName.startsWith ( " FMEObjects Gateway" ) )
796821 {
797822 longName = " FMEObjects Gateway" ;
823+ trLongName = QObject::tr ( " FMEObjects Gateway" );
798824 glob = " *.fdd" ;
825+ ext = " fdd" ;
799826 }
800827 else if ( driverName.startsWith ( " GeoJSON" ) )
801828 {
802829 longName = " GeoJSON" ;
830+ trLongName = QObject::tr ( " GeoJSON" );
803831 glob = " *.geojson" ;
832+ ext = " geojson" ;
804833 }
805834 else if ( driverName.startsWith ( " GeoRSS" ) )
806835 {
807836 longName = " GeoRSS" ;
837+ trLongName = QObject::tr ( " GeoRSS" );
808838 glob = " *.xml" ;
839+ ext = " xml" ;
809840 }
810841 else if ( driverName.startsWith ( " GML" ) )
811842 {
812843 longName = " Geography Markup Language (GML)" ;
844+ trLongName = QObject::tr ( " Geography Markup Language (GML)" );
813845 glob = " *.gml" ;
846+ ext = " gml" ;
814847 }
815848 else if ( driverName.startsWith ( " GMT" ) )
816849 {
817850 longName = " Generic Mapping Tools (GMT)" ;
851+ trLongName = QObject::tr ( " Generic Mapping Tools (GMT)" );
818852 glob = " *.gmt" ;
853+ ext = " gmt" ;
819854 }
820855 else if ( driverName.startsWith ( " GPX" ) )
821856 {
822857 longName = " GPS eXchange Format" ;
858+ trLongName = QObject::tr ( " GPS eXchange Format" );
823859 glob = " *.gpx" ;
860+ ext = " gpx" ;
824861 }
825862 else if ( driverName.startsWith ( " Interlis 1" ) )
826863 {
827864 longName = " INTERLIS 1" ;
865+ trLongName = QObject::tr ( " INTERLIS 1" );
828866 glob = " *.itf *.xml *.ili" ;
867+ ext = " ili" ;
829868 }
830869 else if ( driverName.startsWith ( " Interlis 2" ) )
831870 {
832871 longName = " INTERLIS 2" ;
872+ trLongName = QObject::tr ( " INTERLIS 2" );
833873 glob = " *.itf *.xml *.ili" ;
874+ ext = " ili" ;
834875 }
835876 else if ( driverName.startsWith ( " KML" ) )
836877 {
837878 longName = " Keyhole Markup Language (KML)" ;
879+ trLongName = QObject::tr ( " Keyhole Markup Language (KML)" );
838880 glob = " *.kml" ;
881+ ext = " kml" ;
839882 }
840883 else if ( driverName.startsWith ( " MapInfo File" ) )
841884 {
842885 longName = " Mapinfo File" ;
886+ trLongName = QObject::tr ( " Mapinfo File" );
843887 glob = " *.mif *.tab" ;
888+ ext = " mif" ;
844889 }
845890 else if ( driverName.startsWith ( " DGN" ) )
846891 {
847892 longName = " Microstation DGN" ;
893+ trLongName = QObject::tr ( " Microstation DGN" );
848894 glob = " *.dgn" ;
895+ ext = " dgn" ;
849896 }
850897 else if ( driverName.startsWith ( " S57" ) )
851898 {
852899 longName = " S-57 Base file" ;
900+ trLongName = QObject::tr ( " S-57 Base file" );
853901 glob = " *.000" ;
902+ ext = " 000" ;
854903 }
855904 else if ( driverName.startsWith ( " SDTS" ) )
856905 {
857906 longName = " Spatial Data Transfer Standard (SDTS)" ;
907+ trLongName = QObject::tr ( " Spatial Data Transfer Standard (SDTS)" );
858908 glob = " *catd.ddf" ;
909+ ext = " ddf" ;
859910 }
860911 else if ( driverName.startsWith ( " SQLite" ) )
861912 {
862913 longName = " SQLite" ;
914+ trLongName = QObject::tr ( " SQLite" );
863915 glob = " *.sqlite" ;
916+ ext = " sqlite" ;
864917 }
865918 else if ( driverName.startsWith ( " DXF" ) )
866919 {
867920 longName = " AutoCAD DXF" ;
921+ trLongName = QObject::tr ( " AutoCAD DXF" );
868922 glob = " *.dxf" ;
923+ ext = " dxf" ;
869924 }
870925 else if ( driverName.startsWith ( " Geoconcept" ) )
871926 {
872927 longName = " Geoconcept" ;
928+ trLongName = QObject::tr ( " Geoconcept" );
873929 glob = " *.gxt *.txt" ;
930+ ext = " gxt" ;
931+ }
932+ else
933+ {
934+ return false ;
874935 }
875936
876- return QPair<QString, QString>( longName, glob ) ;
937+ return true ;
877938}
0 commit comments