Skip to content
Permalink
Browse files

Use QgsFieldCombo for map tip field combo boxes

  • Loading branch information
nyalldawson committed Feb 17, 2016
1 parent b6c2529 commit cbc830be380acabca263fd83338e0cde6a4f3cee
Showing with 35 additions and 40 deletions.
  1. +9 −20 src/app/qgsvectorlayerproperties.cpp
  2. +26 −20 src/ui/qgsvectorlayerpropertiesbase.ui
@@ -111,6 +111,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(

connect( mOptionsStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( mOptionsStackedWidget_CurrentChanged( int ) ) );

fieldComboBox->setLayer( lyr );
displayFieldComboBox->setLayer( lyr );
connect( insertFieldButton, SIGNAL( clicked() ), this, SLOT( insertField() ) );
connect( insertExpressionButton, SIGNAL( clicked() ), this, SLOT( insertExpression() ) );

@@ -332,14 +334,10 @@ void QgsVectorLayerProperties::insertField()
{
// Convert the selected field to an expression and
// insert it into the action at the cursor position

if ( !fieldComboBox->currentText().isNull() )
{
QString field = "[% \"";
field += fieldComboBox->currentText();
field += "\" %]";
htmlMapTip->insertPlainText( field );
}
QString field = "[% \"";
field += fieldComboBox->currentField();
field += "\" %]";
htmlMapTip->insertPlainText( field );
}

void QgsVectorLayerProperties::insertExpression()
@@ -373,16 +371,15 @@ void QgsVectorLayerProperties::insertExpression()

void QgsVectorLayerProperties::setDisplayField( const QString& name )
{
int idx = displayFieldComboBox->findText( name );
if ( idx == -1 )
if ( layer->fields().fieldNameIndex( name ) == -1 )
{
htmlRadio->setChecked( true );
htmlMapTip->setPlainText( name );
}
else
{
fieldComboRadio->setChecked( true );
displayFieldComboBox->setCurrentIndex( idx );
displayFieldComboBox->setField( name );
}
}

@@ -415,14 +412,6 @@ void QgsVectorLayerProperties::syncToLayer( void )
pbnQueryBuilder->setToolTip( tr( "Stop editing mode to enable this." ) );
}

//get field list for display field combo
const QgsFields& myFields = layer->fields();
for ( int idx = 0; idx < myFields.count(); ++idx )
{
displayFieldComboBox->addItem( myFields[idx].name() );
fieldComboBox->addItem( myFields[idx].name() );
}

setDisplayField( layer->displayField() );

// set up the scale based layer visibility stuff....
@@ -573,7 +562,7 @@ void QgsVectorLayerProperties::apply()

if ( fieldComboRadio->isChecked() )
{
layer->setDisplayField( displayFieldComboBox->currentText() );
layer->setDisplayField( displayFieldComboBox->currentField() );
}

actionDialog->apply();
@@ -273,7 +273,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>6</number>
</property>
<widget class="QWidget" name="mOptsPage_General">
<layout class="QVBoxLayout" name="verticalLayout_14">
@@ -302,8 +302,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>537</height>
<width>331</width>
<height>431</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -600,8 +600,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>537</height>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
@@ -701,8 +701,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>537</height>
<width>123</width>
<height>38</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
@@ -783,8 +783,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>537</height>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_20">
@@ -843,8 +843,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>537</height>
<width>721</width>
<height>199</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -1022,7 +1022,7 @@
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Map Tip display text</string>
<string>Map tip display text</string>
</property>
<property name="syncGroup" stdset="0">
<string notr="true">vectordisplay</string>
@@ -1066,7 +1066,7 @@
</spacer>
</item>
<item>
<widget class="QComboBox" name="fieldComboBox">
<widget class="QgsFieldComboBox" name="fieldComboBox">
<property name="enabled">
<bool>false</bool>
</property>
@@ -1139,7 +1139,7 @@
</layout>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="displayFieldComboBox">
<widget class="QgsFieldComboBox" name="displayFieldComboBox">
<property name="enabled">
<bool>false</bool>
</property>
@@ -1181,8 +1181,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>537</height>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@@ -1247,8 +1247,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>537</height>
<width>134</width>
<height>113</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
@@ -1415,8 +1415,8 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-104</y>
<width>714</width>
<y>0</y>
<width>393</width>
<height>641</height>
</rect>
</property>
@@ -1916,6 +1916,12 @@
<header location="global">qgsvariableeditorwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFieldComboBox</class>
<extends>QComboBox</extends>
<header>qgsfieldcombobox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mOptionsListWidget</tabstop>

0 comments on commit cbc830b

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