mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
This change allows the attributes of multiple features to be edited simultaneously. It is enabled when the attribute table dialog is in "form mode", via a new "multi edit" button on the toolbar. In this mode, attribute value changes will apply to all selected features. New widgets appear next to each editor widget allowing for display of the current multi-edit state and for rolling back changes on a field-by-field basis. Changes are made as a single edit command, so pressing undo will rollback the attribute changes for all selected features at once. Multiedit mode is only available for auto generated and drag and drop forms - it is not supported by custom ui forms. Sponsored by Kanton Basel Stadt
189 lines
5.6 KiB
Plaintext
189 lines
5.6 KiB
Plaintext
/***************************************************************************
|
|
qgsattributeform.h
|
|
--------------------------------------
|
|
Date : 3.5.2014
|
|
Copyright : (C) 2014 Matthias Kuhn
|
|
Email : matthias at opengis dot ch
|
|
***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
class QgsAttributeForm : QWidget
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsattributeform.h>
|
|
%End
|
|
|
|
public:
|
|
|
|
//! Form modes
|
|
enum Mode
|
|
{
|
|
SingleEditMode, /*!< Single edit mode, for editing a single feature */
|
|
MultiEditMode, /*!< Multi edit mode, for editing fields of multiple features at once */
|
|
// TODO: SearchMode, /*!< Form values are used for searching/filtering the layer */
|
|
};
|
|
|
|
explicit QgsAttributeForm( QgsVectorLayer* vl, const QgsFeature& feature = QgsFeature(), const QgsAttributeEditorContext& context = QgsAttributeEditorContext(), QWidget *parent /TransferThis/ = 0 );
|
|
~QgsAttributeForm();
|
|
|
|
const QgsFeature& feature();
|
|
|
|
/**
|
|
* Hides the button box (Ok/Cancel) and enables auto-commit
|
|
*/
|
|
void hideButtonBox();
|
|
|
|
/**
|
|
* Shows the button box (Ok/Cancel) and disables auto-commit
|
|
*/
|
|
void showButtonBox();
|
|
|
|
/**
|
|
* Disconnects the button box (Ok/Cancel) from the accept/resetValues slots
|
|
* If this method is called, you have to create these connections from outside
|
|
*/
|
|
void disconnectButtonBox();
|
|
|
|
/**
|
|
* Takes ownership
|
|
* @param iface
|
|
*/
|
|
void addInterface( QgsAttributeFormInterface* iface /Transfer/ );
|
|
|
|
/**
|
|
* Returns the layer for which this form is shown
|
|
*
|
|
* @return Layer
|
|
*/
|
|
QgsVectorLayer* layer();
|
|
|
|
/**
|
|
* Returns if the form is currently in editable mode.
|
|
*
|
|
* @return Editable mode of this form
|
|
*/
|
|
bool editable();
|
|
|
|
/** Returns the current mode of the form.
|
|
* @note added in QGIS 2.16
|
|
* @see setMode()
|
|
*/
|
|
Mode mode() const;
|
|
|
|
/** Sets the current mode of the form.
|
|
* @param mode form mode
|
|
* @note added in QGIS 2.16
|
|
* @see mode()
|
|
*/
|
|
void setMode( Mode mode );
|
|
|
|
/**
|
|
* Toggles the form mode between edit feature and add feature.
|
|
* If set to true, the dialog will be editable even with an invalid feature.
|
|
* If set to true, the dialog will add a new feature when the form is accepted.
|
|
*
|
|
* @param isAddDialog If set to true, turn this dialog into an add feature dialog.
|
|
*/
|
|
void setIsAddDialog( bool isAddDialog );
|
|
|
|
/**
|
|
* Sets the edit command message (Undo) that will be used when the dialog is accepted
|
|
*
|
|
* @param message The message
|
|
*/
|
|
void setEditCommandMessage( const QString& message );
|
|
|
|
/**
|
|
* Intercepts keypress on custom form (escape should not close it)
|
|
*
|
|
* @param object The object for which the event has been sent
|
|
* @param event The event which is being filtered
|
|
*
|
|
* @return true if the event has been handled (key was ESC)
|
|
*/
|
|
bool eventFilter( QObject* object, QEvent* event );
|
|
|
|
/** Sets all feature IDs which are to be edited if the form is in multiedit mode
|
|
* @param fids feature ID list
|
|
* @note added in QGIS 2.16
|
|
*/
|
|
void setMultiEditFeatureIds( const QgsFeatureIds& fids );
|
|
|
|
signals:
|
|
/**
|
|
* Notifies about changes of attributes
|
|
*
|
|
* @param attribute The name of the attribute that changed.
|
|
* @param value The new value of the attribute.
|
|
*/
|
|
void attributeChanged( const QString& attribute, const QVariant& value );
|
|
|
|
/**
|
|
* Will be emitted before the feature is saved. Use this signal to perform sanity checks.
|
|
* You can set the parameter ok to false to notify the form that you don't want it to be saved.
|
|
* If you want the form to be saved, leave the parameter untouched.
|
|
*
|
|
* @param ok Set this parameter to false if you don't want the form to be saved
|
|
* @note not available in python bindings
|
|
*/
|
|
// void beforeSave( bool& ok );
|
|
|
|
/**
|
|
* Is emitted, when a feature is changed or added
|
|
*/
|
|
void featureSaved( const QgsFeature& feature );
|
|
|
|
public slots:
|
|
/**
|
|
* Call this to change the content of a given attribute. Will update the editor(s) related to this field.
|
|
*
|
|
* @param field The field to change
|
|
* @param value The new value
|
|
*/
|
|
void changeAttribute( const QString& field, const QVariant& value );
|
|
|
|
/**
|
|
* Update all editors to correspond to a different feature.
|
|
*
|
|
* @param feature The feature which will be represented by the form
|
|
*/
|
|
void setFeature( const QgsFeature& feature );
|
|
|
|
/**
|
|
* Save all the values from the editors to the layer.
|
|
*
|
|
* @return True if successful
|
|
*/
|
|
bool save();
|
|
|
|
/**
|
|
* Alias for save()
|
|
*
|
|
* @deprecated
|
|
*/
|
|
void accept() /Deprecated/;
|
|
|
|
/**
|
|
* Alias for resetValues()
|
|
*
|
|
* @deprecated
|
|
*/
|
|
void reject() /Deprecated/;
|
|
|
|
/**
|
|
* Sets all values to the values of the current feature
|
|
*/
|
|
void resetValues();
|
|
|
|
/**
|
|
* reload current feature
|
|
*/
|
|
void refreshFeature();
|
|
};
|