Skip to content

Commit 7175976

Browse files
committed
fix #7865
1 parent b697371 commit 7175976

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/gui/qgsnewvectorlayerdialog.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "qgsnewvectorlayerdialog.h"
1919
#include "qgsapplication.h"
20-
//#include "qgisapp.h" // <- for theme icons
2120
#include "qgis.h"
2221
#include "qgslogger.h"
2322
#include "qgscoordinatereferencesystem.h"
@@ -38,22 +37,24 @@ QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WFlags fl
3837
QSettings settings;
3938
restoreGeometry( settings.value( "/Windows/NewVectorLayer/geometry" ).toByteArray() );
4039

41-
// TODO: do it without QgisApp
42-
//mAddAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionNewAttribute.png" ) );
43-
//mRemoveAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionDeleteAttribute.png" ) );
40+
mAddAttributeButton->setIcon( QgsApplication::getThemeIcon( "/mActionNewAttribute.png" ) );
41+
mRemoveAttributeButton->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteAttribute.png" ) );
4442
mTypeBox->addItem( tr( "Text data" ), "String" );
4543
mTypeBox->addItem( tr( "Whole number" ), "Integer" );
4644
mTypeBox->addItem( tr( "Decimal number" ), "Real" );
45+
mTypeBox->addItem( tr( "Date" ), "Date" );
4746

4847
mWidth->setValidator( new QIntValidator( 1, 255, this ) );
4948
mPrecision->setValidator( new QIntValidator( 0, 15, this ) );
5049

5150
mPointRadioButton->setChecked( true );
5251
mFileFormatComboBox->addItem( tr( "ESRI Shapefile" ), "ESRI Shapefile" );
53-
/* Disabled until provider properly supports editing the created file formats */
54-
//mFileFormatComboBox->addItem( tr( "Comma Separated Value" ), "Comma Separated Value" );
55-
//mFileFormatComboBox->addItem(tr( "GML"), "GML" );
56-
//mFileFormatComboBox->addItem(tr( "Mapinfo File" ), "Mapinfo File" );
52+
#if 0
53+
// Disabled until provider properly supports editing the created file formats
54+
mFileFormatComboBox->addItem( tr( "Comma Separated Value" ), "Comma Separated Value" );
55+
mFileFormatComboBox->addItem( tr( "GML" ), "GML" );
56+
mFileFormatComboBox->addItem( tr( "Mapinfo File" ), "Mapinfo File" );
57+
#endif
5758
if ( mFileFormatComboBox->count() == 1 )
5859
{
5960
mFileFormatComboBox->setVisible( false );

src/gui/qgsquerybuilder.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,15 @@ void QgsQueryBuilder::fillValues( int idx, int limit )
115115

116116
for ( int i = 0; i < values.size(); i++ )
117117
{
118-
QStandardItem *myItem = new QStandardItem( values[i].isNull() ? nullValue : values[i].toString() );
118+
QString value;
119+
if ( values[i].isNull() )
120+
value = nullValue;
121+
else if ( values[i].type() == QVariant::Date && mLayer->providerType() == "ogr" && mLayer->storageType() == "ESRI Shapefile" )
122+
value = values[i].toDate().toString( "yyyy/MM/dd" );
123+
else
124+
value = values[i].toString();
125+
126+
QStandardItem *myItem = new QStandardItem( value );
119127
myItem->setEditable( false );
120128
myItem->setData( values[i], Qt::UserRole + 1 );
121129
mModelValues->insertRow( mModelValues->rowCount(), myItem );
@@ -307,6 +315,8 @@ void QgsQueryBuilder::on_lstValues_doubleClicked( const QModelIndex &index )
307315
QVariant value = mModelValues->data( index, Qt::UserRole + 1 );
308316
if ( value.isNull() )
309317
txtSQL->insertPlainText( "NULL" );
318+
else if ( value.type() == QVariant::Date && mLayer->providerType() == "ogr" && mLayer->storageType() == "ESRI Shapefile" )
319+
txtSQL->insertPlainText( "'" + value.toDate().toString( "yyyy/MM/dd" ) + "'" );
310320
else if ( value.type() == QVariant::Int || value.type() == QVariant::Double || value.type() == QVariant::LongLong )
311321
txtSQL->insertPlainText( value.toString() );
312322
else

src/providers/ogr/qgsogrprovider.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
20192019
}
20202020
else
20212021
{
2022+
QgsMessageLog::logMessage( QObject::tr( "field %1 with unsupported type %2 skipped" ).arg( it->first ).arg( fields[0] ), QObject::tr( "OGR" ) );
20222023
continue;
20232024
}
20242025

0 commit comments

Comments
 (0)