Skip to content
Permalink
Browse files

rename static variables

since they're not really default values
  • Loading branch information
3nids committed Jan 3, 2018
1 parent 919cbec commit 69cfdc4fcfb68bd940a10b1b3b685afb22fbb6d6
@@ -21,11 +21,11 @@ the field configuration.
#include "qgsdatetimefieldformatter.h"
%End
public:
static const QString DEFAULT_DATE_FORMAT;
static const QString DEFAULT_TIME_FORMAT;
static const QString DEFAULT_DATETIME_FORMAT;
static const QString DEFAULT_ISO_FORMAT;
static const QString DEFAULT_ISO_DISPLAY_FORMAT;
static const QString DATE_FORMAT;
static const QString TIME_FORMAT;
static const QString DATETIME_FORMAT;
static const QString QT_ISO_FORMAT;
static const QString DISPLAY_FOR_ISO_FORMAT;

QgsDateTimeFieldFormatter();
%Docstring
@@ -19,13 +19,13 @@
#include "qgsfield.h"
#include "qgsvectorlayer.h"

const QString QgsDateTimeFieldFormatter::DEFAULT_DATE_FORMAT = QStringLiteral( "yyyy-MM-dd" );
const QString QgsDateTimeFieldFormatter::DEFAULT_TIME_FORMAT = QStringLiteral( "HH:mm:ss" );
const QString QgsDateTimeFieldFormatter::DEFAULT_DATETIME_FORMAT = QStringLiteral( "yyyy-MM-dd HH:mm:ss" );
const QString QgsDateTimeFieldFormatter::DATE_FORMAT = QStringLiteral( "yyyy-MM-dd" );
const QString QgsDateTimeFieldFormatter::TIME_FORMAT = QStringLiteral( "HH:mm:ss" );
const QString QgsDateTimeFieldFormatter::DATETIME_FORMAT = QStringLiteral( "yyyy-MM-dd HH:mm:ss" );
// we need to use Qt::ISODate rather than a string format definition in QDate::fromString
const QString QgsDateTimeFieldFormatter::DEFAULT_ISO_FORMAT = QStringLiteral( "Qt ISO Date" );
const QString QgsDateTimeFieldFormatter::QT_ISO_FORMAT = QStringLiteral( "Qt ISO Date" );
// but QDateTimeEdit::setDisplayFormat only accepts string formats, so use with time zone by default
const QString QgsDateTimeFieldFormatter::DEFAULT_ISO_DISPLAY_FORMAT = QStringLiteral( "yyyy-MM-dd HH:mm:ss+t" );
const QString QgsDateTimeFieldFormatter::DISPLAY_FOR_ISO_FORMAT = QStringLiteral( "yyyy-MM-dd HH:mm:ss+t" );


QString QgsDateTimeFieldFormatter::id() const
@@ -76,12 +76,12 @@ QString QgsDateTimeFieldFormatter::defaultFormat( QVariant::Type type )
switch ( type )
{
case QVariant::DateTime:
return QgsDateTimeFieldFormatter::DEFAULT_DATETIME_FORMAT;
return QgsDateTimeFieldFormatter::DATETIME_FORMAT;
break;
case QVariant::Time:
return QgsDateTimeFieldFormatter::DEFAULT_TIME_FORMAT;
return QgsDateTimeFieldFormatter::TIME_FORMAT;
break;
default:
return QgsDateTimeFieldFormatter::DEFAULT_DATE_FORMAT;
return QgsDateTimeFieldFormatter::DATE_FORMAT;
}
}
@@ -30,11 +30,11 @@
class CORE_EXPORT QgsDateTimeFieldFormatter : public QgsFieldFormatter
{
public:
static const QString DEFAULT_DATE_FORMAT;
static const QString DEFAULT_TIME_FORMAT;
static const QString DEFAULT_DATETIME_FORMAT;
static const QString DEFAULT_ISO_FORMAT;
static const QString DEFAULT_ISO_DISPLAY_FORMAT;
static const QString DATE_FORMAT;
static const QString TIME_FORMAT;
static const QString DATETIME_FORMAT;
static const QString QT_ISO_FORMAT;
static const QString DISPLAY_FOR_ISO_FORMAT;

/**
* Default constructor of field formatter for a date time field.
@@ -24,11 +24,11 @@ QgsDateTimeEditConfig::QgsDateTimeEditConfig( QgsVectorLayer *vl, int fieldIdx,
setupUi( this );

mFieldFormatComboBox->clear();
mFieldFormatComboBox->addItem( tr( "Date" ), QgsDateTimeFieldFormatter::DEFAULT_DATE_FORMAT );
mFieldFormatComboBox->addItem( tr( "Time" ), QgsDateTimeFieldFormatter::DEFAULT_TIME_FORMAT );
mFieldFormatComboBox->addItem( tr( "Date time" ), QgsDateTimeFieldFormatter::DEFAULT_DATETIME_FORMAT );
mFieldFormatComboBox->addItem( tr( "ISO date time" ), QgsDateTimeFieldFormatter::DEFAULT_ISO_FORMAT );
mFieldFormatComboBox->addItem( tr( "Custom" ), "" );
mFieldFormatComboBox->addItem( tr( "Date" ), QgsDateTimeFieldFormatter::DATE_FORMAT );
mFieldFormatComboBox->addItem( tr( "Time" ), QgsDateTimeFieldFormatter::TIME_FORMAT );
mFieldFormatComboBox->addItem( tr( "Date time" ), QgsDateTimeFieldFormatter::DATETIME_FORMAT );
mFieldFormatComboBox->addItem( tr( "ISO date time" ), QgsDateTimeFieldFormatter::QT_ISO_FORMAT );
mFieldFormatComboBox->addItem( tr( "Custom" ), QString() );

mDemoDateTimeEdit->setDateTime( QDateTime::currentDateTime() );

@@ -84,9 +84,9 @@ void QgsDateTimeEditConfig::updateDisplayFormat( const QString &fieldFormat )
if ( mDisplayFormatComboBox->currentIndex() == 0 )
{
// i.e. display format is default
if ( mFieldFormatComboBox->currentData() == QgsDateTimeFieldFormatter::DEFAULT_ISO_FORMAT )
if ( mFieldFormatComboBox->currentData() == QgsDateTimeFieldFormatter::QT_ISO_FORMAT )
{
mDisplayFormatEdit->setText( QgsDateTimeFieldFormatter::DEFAULT_ISO_DISPLAY_FORMAT );
mDisplayFormatEdit->setText( QgsDateTimeFieldFormatter::DISPLAY_FOR_ISO_FORMAT );
}
else
{
@@ -123,7 +123,7 @@ QVariantMap QgsDateTimeEditConfig::config()
{
QVariantMap myConfig;

myConfig.insert( QStringLiteral( "field_iso_format" ), mFieldFormatEdit->text() == QgsDateTimeFieldFormatter::DEFAULT_ISO_FORMAT );
myConfig.insert( QStringLiteral( "field_iso_format" ), mFieldFormatEdit->text() == QgsDateTimeFieldFormatter::QT_ISO_FORMAT );
myConfig.insert( QStringLiteral( "field_format" ), mFieldFormatEdit->text() );
myConfig.insert( QStringLiteral( "display_format" ), mDisplayFormatEdit->text() );
myConfig.insert( QStringLiteral( "calendar_popup" ), mCalendarPopupCheckBox->isChecked() );
@@ -47,7 +47,7 @@ QVariant QgsDateTimeSearchWidgetWrapper::value() const
return QDateTime();

const QString fieldFormat = config( QStringLiteral( "field_format" ), QgsDateTimeFieldFormatter::defaultFormat( layer()->fields().at( mFieldIdx ).type() ) ).toString();
if ( fieldFormat == QgsDateTimeFieldFormatter::DEFAULT_ISO_FORMAT )
if ( fieldFormat == QgsDateTimeFieldFormatter::QT_ISO_FORMAT )
{
return mDateTimeEdit->dateTime().toString( Qt::ISODate );
}

Large diffs are not rendered by default.

0 comments on commit 69cfdc4

Please sign in to comment.
You can’t perform that action at this time.