Skip to content

Commit

Permalink
rename static variables
Browse files Browse the repository at this point in the history
since they're not really default values
  • Loading branch information
3nids committed Jan 3, 2018
1 parent 919cbec commit 69cfdc4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions python/core/fieldformatter/qgsdatetimefieldformatter.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/core/fieldformatter/qgsdatetimefieldformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
10 changes: 5 additions & 5 deletions src/core/fieldformatter/qgsdatetimefieldformatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions src/gui/editorwidgets/qgsdatetimeeditconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/editorwidgets/qgsdatetimeeditconfig.ui

Large diffs are not rendered by default.

0 comments on commit 69cfdc4

Please sign in to comment.