Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use QgsFieldComboBox instead of a plain combo
  • Loading branch information
elpaso committed Jun 24, 2019
1 parent f220a7f commit 7db0cca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
16 changes: 3 additions & 13 deletions src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -289,7 +289,8 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsMapCanvas *mapCanvas, QWidg
mCboDistanceThreshold->setCurrentText( mySettings.value( QStringLiteral( "gps/distanceThreshold" ), 0 ).toString() );

// Timestamp

mCboTimestampField->setAllowEmptyFieldName( true );
mCboTimestampField->setFilters( QgsFieldProxyModel::Filter::String | QgsFieldProxyModel::Filter::DateTime );
// Qt::LocalTime 0 Locale dependent time (Timezones and Daylight Savings Time).
// Qt::UTC 1 Coordinated Universal Time, replaces Greenwich Mean Time.
// SKIP this one: Qt::OffsetFromUTC 2 An offset in seconds from Coordinated Universal Time.
Expand Down Expand Up @@ -1400,20 +1401,9 @@ void QgsGpsInformationWidget::updateTimestampDestinationFields( QgsMapLayer *map
mPopulatingFields = true;
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mapLayer );
mGboxTimestamp->setEnabled( false );
mCboTimestampField->clear();
// Empty option by default
mCboTimestampField->addItem( QString() );
if ( vlayer )
{
// Search for suitable fields
const auto fields { vlayer->fields() };
for ( const auto &f : fields )
{
if ( f.type() == QVariant::String || f.type() == QVariant::DateTime )
{
mCboTimestampField->addItem( f.name() );
}
}
mCboTimestampField->setLayer( mapLayer );
if ( mCboTimestampField->count() > 1 )
{
mGboxTimestamp->setEnabled( true );
Expand Down
7 changes: 6 additions & 1 deletion src/ui/qgsgpsinformationwidgetbase.ui
Expand Up @@ -1115,7 +1115,7 @@ gray = no data
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="mCboTimestampField"/>
<widget class="QgsFieldComboBox" name="mCboTimestampField"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mLblTimestampFormat">
Expand Down Expand Up @@ -1374,6 +1374,11 @@ gray = no data
<extends>QToolButton</extends>
<header>qgscolorbutton.h</header>
</customwidget>
<customwidget>
<class>QgsFieldComboBox</class>
<extends>QComboBox</extends>
<header>qgsfieldcombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mBtnCloseFeature</tabstop>
Expand Down

0 comments on commit 7db0cca

Please sign in to comment.