Skip to content
Permalink
Browse files

Address some GUI issues on the field calculator

 * Info labels for edit mode turn on was not shown
 * Ok button was active when opening the field calculator even with no input (Fix #11403)
  • Loading branch information
m-kuhn committed Oct 14, 2014
1 parent 9f063df commit 0c4a501551638c5aab2eeff85740e67431d66d71
Showing with 154 additions and 118 deletions.
  1. +18 −7 src/app/qgsfieldcalculator.cpp
  2. +136 −111 src/ui/qgsfieldcalculatorbase.ui
@@ -58,15 +58,17 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl )
mOutputFieldNameLineEdit->setMaxLength( 10 );
}

if( !( vl->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes ) )
if ( !( vl->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes ) )
{
mCreateVirtualFieldCheckbox->setChecked( true );
mCreateVirtualFieldCheckbox->setEnabled( false );
mOnlyVirtualFieldsInfoLabel->setVisible( true );
mInfoIcon->setVisible( true );
}
else
{
mOnlyVirtualFieldsInfoLabel->setVisible( false );
mInfoIcon->setVisible( false );
}

if ( !( vl->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) )
@@ -100,9 +102,14 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl )
mNewFieldGroupBox->setCheckable( false );
}

if ( ( mNewFieldGroupBox->isChecked() && mCreateVirtualFieldCheckbox->isChecked() ) || mVectorLayer->isEditable() )
if (( mNewFieldGroupBox->isChecked() && mCreateVirtualFieldCheckbox->isChecked() ) || mVectorLayer->isEditable() )
{
mEditModeAutoTurnOnLabel->setVisible( false );
mInfoIcon->setVisible( false );
}
else
{
mInfoIcon->setVisible( true );
}

bool hasselection = vl->selectedFeatureCount() > 0;
@@ -112,8 +119,9 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl )

builder->loadRecent( "fieldcalc" );

mEditModeAutoTurnOnLabel->setPixmap( style()->standardPixmap( QStyle::SP_MessageBoxInformation ) );
mOnlyVirtualFieldsInfoLabel->setPixmap( style()->standardPixmap( QStyle::SP_MessageBoxInformation ) );
mInfoIcon->setPixmap( style()->standardPixmap( QStyle::SP_MessageBoxInformation ) );

setOkButtonState();

QSettings settings;
restoreGeometry( settings.value( "/Windows/QgsFieldCalculator/geometry" ).toByteArray() );
@@ -304,7 +312,7 @@ void QgsFieldCalculator::populateOutputFieldTypes()
void QgsFieldCalculator::on_mNewFieldGroupBox_toggled( bool on )
{
mUpdateExistingGroupBox->setChecked( !on );
if ( on && ! ( mVectorLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes ) )
if ( on && !( mVectorLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes ) )
{
mOnlyVirtualFieldsInfoLabel->setVisible( true );
}
@@ -313,14 +321,16 @@ void QgsFieldCalculator::on_mNewFieldGroupBox_toggled( bool on )
mOnlyVirtualFieldsInfoLabel->setVisible( false );
}

if ( ( mNewFieldGroupBox->isChecked() && mCreateVirtualFieldCheckbox->isChecked() ) || mVectorLayer->isEditable() )
if (( mNewFieldGroupBox->isChecked() && mCreateVirtualFieldCheckbox->isChecked() ) || mVectorLayer->isEditable() )
{
mEditModeAutoTurnOnLabel->setVisible( false );
}
else
{
mEditModeAutoTurnOnLabel->setVisible( true );
}

mInfoIcon->setVisible( mOnlyVirtualFieldsInfoLabel->isVisible() || mEditModeAutoTurnOnLabel->isVisible() );
}

void QgsFieldCalculator::on_mUpdateExistingGroupBox_toggled( bool on )
@@ -343,14 +353,15 @@ void QgsFieldCalculator::on_mCreateVirtualFieldCheckbox_stateChanged( int state
mOnlyUpdateSelectedCheckBox->setChecked( false );
mOnlyUpdateSelectedCheckBox->setEnabled( state != Qt::Checked && mVectorLayer->selectedFeatureCount() > 0 );

if ( ( mNewFieldGroupBox->isChecked() && mCreateVirtualFieldCheckbox->isChecked() ) || mVectorLayer->isEditable() )
if (( mNewFieldGroupBox->isChecked() && mCreateVirtualFieldCheckbox->isChecked() ) || mVectorLayer->isEditable() )
{
mEditModeAutoTurnOnLabel->setVisible( false );
}
else
{
mEditModeAutoTurnOnLabel->setVisible( true );
}
mInfoIcon->setVisible( mOnlyVirtualFieldsInfoLabel->isVisible() || mEditModeAutoTurnOnLabel->isVisible() );
}


@@ -14,6 +14,114 @@
<string>Field calculator</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="mOnlyUpdateSelectedCheckBox">
<property name="text">
<string>Only update selected features</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="mInfoIcon">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="mEditModeAutoTurnOnLabel">
<property name="text">
<string>You are editing information on this layer but the layer is currently not in edit mode. If you click Ok, edit mode will automatically be turned on.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="mOnlyVirtualFieldsInfoLabel">
<property name="text">
<string>This layer does not support adding new provider fields. You can only add virtual fields.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="mUpdateExistingGroupBox">
<property name="title">
<string>Update existing field</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="mExistingFieldComboBox"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QgsExpressionBuilderWidget" name="builder" native="true">
<property name="autoFillBackground">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="mNewFieldGroupBox">
<property name="sizePolicy">
@@ -53,43 +161,44 @@
<property name="verticalSpacing">
<number>3</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="mFieldNameLabel">
<item row="3" column="0">
<widget class="QLabel" name="mOutputFieldTypeLabel">
<property name="text">
<string>Output field name</string>
<string>Output field type</string>
</property>
<property name="buddy">
<cstring>mOutputFieldNameLineEdit</cstring>
<cstring>mOutputFieldTypeComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="mOutputFieldNameLineEdit"/>
<item row="4" column="3">
<widget class="QSpinBox" name="mOutputFieldPrecisionSpinBox">
<property name="value">
<number>2</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mOutputFieldTypeLabel">
<widget class="QLabel" name="mFieldNameLabel">
<property name="text">
<string>Output field type</string>
<string>Output field name</string>
</property>
<property name="buddy">
<cstring>mOutputFieldTypeComboBox</cstring>
<cstring>mOutputFieldNameLineEdit</cstring>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="mOutputFieldTypeComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mOutputFieldWidthLabel">
<item row="4" column="2">
<widget class="QLabel" name="mOutputFieldPrecisionLabel">
<property name="text">
<string>Output field width</string>
<string>Precision</string>
</property>
<property name="buddy">
<cstring>mOutputFieldWidthSpinBox</cstring>
<cstring>mOutputFieldPrecisionSpinBox</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QSpinBox" name="mOutputFieldWidthSpinBox">
<property name="toolTip">
<string>Width of complete output. For example 123,456 means 6 as field width.</string>
@@ -102,24 +211,23 @@
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="mOutputFieldPrecisionLabel">
<item row="4" column="0">
<widget class="QLabel" name="mOutputFieldWidthLabel">
<property name="text">
<string>Precision</string>
<string>Output field width</string>
</property>
<property name="buddy">
<cstring>mOutputFieldPrecisionSpinBox</cstring>
<cstring>mOutputFieldWidthSpinBox</cstring>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QSpinBox" name="mOutputFieldPrecisionSpinBox">
<property name="value">
<number>2</number>
</property>
</widget>
<item row="3" column="1" colspan="3">
<widget class="QComboBox" name="mOutputFieldTypeComboBox"/>
</item>
<item row="2" column="1" colspan="3">
<widget class="QLineEdit" name="mOutputFieldNameLineEdit"/>
</item>
<item row="4" column="0" colspan="4">
<item row="5" column="0" colspan="4">
<widget class="QCheckBox" name="mCreateVirtualFieldCheckbox">
<property name="toolTip">
<string>A virtual field will be recalculated every time it is used and will not be saved in the data provider but in the project.</string>
@@ -132,89 +240,6 @@
</layout>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="mOnlyVirtualFieldsInfoLabel">
<property name="text">
<string>This layer does not support adding new provider fields. You can only add virtual fields.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QgsExpressionBuilderWidget" name="builder" native="true">
<property name="autoFillBackground">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="mOnlyUpdateSelectedCheckBox">
<property name="text">
<string>Only update selected features</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="mUpdateExistingGroupBox">
<property name="title">
<string>Update existing field</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="mExistingFieldComboBox"/>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="mEditModeAutoTurnOnLabel">
<property name="text">
<string>You are editing information on this layer but the layer is currently not in edit mode. If you click Ok, edit mode will automatically be turned on.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>

0 comments on commit 0c4a501

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