mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Provide a UI in the vector layer properties dialog box to set the
field used as the top level field in the Identify Results dialog box. The value is read from and written to .qgs files git-svn-id: http://svn.osgeo.org/qgis/trunk@2222 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
0a18d64e30
commit
62e2c7cf1f
@ -82,14 +82,20 @@ bufferRenderer(layer->
|
||||
// QTextOStream (&ur) << extent->xMax() << ", " << extent->yMax();
|
||||
lblUpperRight->setText(ur.sprintf("%16f, %16f", extent->xMax(), extent->yMax()));
|
||||
std::vector < QgsField > fields = dp->fields();
|
||||
// populate the table and the display field drop-down with the field information
|
||||
// populate the table and the display field drop-down with the field
|
||||
// information
|
||||
|
||||
displayFieldComboBox->insertItem( "" );
|
||||
for (int i = 0; i < fields.size(); i++)
|
||||
{
|
||||
QgsField fld = fields[i];
|
||||
QListViewItem *lvi = new QListViewItem(listViewFields, fld.name(),
|
||||
fld.type(), QString("%1").arg(fld.length()),
|
||||
QString("%1").arg(fld.precision()));
|
||||
}
|
||||
{
|
||||
QgsField fld = fields[i];
|
||||
QListViewItem *lvi = new QListViewItem(listViewFields, fld.name(),
|
||||
fld.type(), QString("%1").arg(fld.length()),
|
||||
QString("%1").arg(fld.precision()));
|
||||
displayFieldComboBox->insertItem( fld.name() );
|
||||
}
|
||||
displayFieldComboBox->setCurrentItem(0); // the blank one
|
||||
|
||||
// set up the scale based layer visibility stuff....
|
||||
chkUseScaleDependentRendering->setChecked(lyr->scaleBasedVisibility());
|
||||
spinMinimumScale->setValue(lyr->minScale());
|
||||
@ -213,6 +219,9 @@ void QgsDlgVectorLayerProperties::apply()
|
||||
layer->setScaleBasedVisibility(chkUseScaleDependentRendering->isChecked());
|
||||
layer->setMinScale(spinMinimumScale->value());
|
||||
layer->setMaxScale(spinMaximumScale->value());
|
||||
|
||||
// update the display field
|
||||
layer->setDisplayField(displayFieldComboBox->currentText());
|
||||
|
||||
if (rendererDirty)
|
||||
{
|
||||
@ -306,6 +315,11 @@ void QgsDlgVectorLayerProperties::setLegendType(QString type)
|
||||
legendtypecombobox->setCurrentText(tr(type));
|
||||
}
|
||||
|
||||
void QgsDlgVectorLayerProperties::setDisplayField(QString name)
|
||||
{
|
||||
displayFieldComboBox->setCurrentText(name);
|
||||
}
|
||||
|
||||
void QgsDlgVectorLayerProperties::reset( void )
|
||||
{
|
||||
actionDialog->init();
|
||||
|
@ -40,6 +40,8 @@ class QgsDlgVectorLayerProperties : public QgsDlgVectorLayerPropertiesBase{
|
||||
void setLegendType(QString type);
|
||||
/**Returns the display name entered in the dialog*/
|
||||
QString displayName();
|
||||
/**Sets the attribute that is used in the Identify Results dialog box*/
|
||||
void setDisplayField(QString name);
|
||||
/**Sets the rendererDirty flag*/
|
||||
void setRendererDirty(bool enabled=true);
|
||||
/**Returns a pointer to the bufferDialog*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -824,6 +824,9 @@ void QgsVectorLayer::select(int number)
|
||||
if (! m_propertiesDialog)
|
||||
{
|
||||
m_propertiesDialog = new QgsDlgVectorLayerProperties(this);
|
||||
// Make sure that the UI starts out with the correct display
|
||||
// field value
|
||||
m_propertiesDialog->setDisplayField(displayField());
|
||||
}
|
||||
|
||||
m_propertiesDialog->reset();
|
||||
@ -1140,7 +1143,11 @@ void QgsVectorLayer::select(int number)
|
||||
{
|
||||
delete m_propertiesDialog;
|
||||
}
|
||||
|
||||
m_propertiesDialog = properties;
|
||||
// Make sure that the UI gets the correct display
|
||||
// field value
|
||||
m_propertiesDialog->setDisplayField(displayField());
|
||||
}
|
||||
|
||||
|
||||
@ -1409,6 +1416,14 @@ bool QgsVectorLayer::readXML_( QDomNode & layer_node )
|
||||
|
||||
setDataProvider( providerKey );
|
||||
|
||||
// get and set the display field if it exists.
|
||||
QDomNode displayFieldNode = layer_node.namedItem("displayfield");
|
||||
if (!displayFieldNode.isNull())
|
||||
{
|
||||
QDomElement e = displayFieldNode.toElement();
|
||||
setDisplayField(e.text());
|
||||
}
|
||||
|
||||
// create and bind a renderer to this layer
|
||||
|
||||
QDomNode singlenode = layer_node.namedItem("singlesymbol");
|
||||
@ -1643,6 +1658,13 @@ QgsVectorLayer:: setDataProvider( QString const & provider )
|
||||
|
||||
layer_node.appendChild( provider );
|
||||
|
||||
// add the display field
|
||||
|
||||
QDomElement dField = document.createElement( "displayfield" );
|
||||
QDomText dFieldText = document.createTextNode( displayField() );
|
||||
dField.appendChild( dFieldText );
|
||||
layer_node.appendChild( dField );
|
||||
|
||||
// add label node
|
||||
|
||||
QDomElement label = document.createElement( "label" );
|
||||
|
@ -70,6 +70,9 @@ class QgsVectorLayer : public QgsMapLayer
|
||||
//! Set the primary display field to be used in the identify results dialog
|
||||
void setDisplayField(QString fldName=0);
|
||||
|
||||
//! Returns the primary display field name used in the identify results dialog
|
||||
const QString displayField() const { return fieldIndex; }
|
||||
|
||||
//! Initialize the context menu
|
||||
void initContextMenu(QgisApp * app);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user