mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[needs-doc] Add a new button in property menu to create auxiliary fields
This commit is contained in:
parent
fa4777ead2
commit
1cfa21512d
@ -190,6 +190,11 @@ Emitted when property definition changes
|
||||
void activated( bool isActive );
|
||||
%Docstring
|
||||
Emitted when the activated status of the widget changes
|
||||
%End
|
||||
|
||||
void createAuxiliaryField();
|
||||
%Docstring
|
||||
Emitted when creating a new auxiliary field
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgspanelwidget.h"
|
||||
#include "qgspropertyassistantwidget.h"
|
||||
#include "qgsauxiliarystorage.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
@ -66,6 +67,8 @@ QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent,
|
||||
|
||||
mActionDescription = new QAction( tr( "Description..." ), this );
|
||||
|
||||
mActionCreateAuxiliaryField = new QAction( tr( "Store data in the project" ), this );
|
||||
|
||||
mActionExpDialog = new QAction( tr( "Edit..." ), this );
|
||||
mActionExpression = nullptr;
|
||||
mActionPasteExpr = new QAction( tr( "Paste" ), this );
|
||||
@ -329,6 +332,20 @@ void QgsPropertyOverrideButton::aboutToShowMenu()
|
||||
|
||||
mDefineMenu->addSeparator();
|
||||
|
||||
// deactivate button if field yet exists
|
||||
mDefineMenu->addAction( mActionCreateAuxiliaryField );
|
||||
|
||||
const QgsAuxiliaryLayer *alayer = mVectorLayer->auxiliaryLayer();
|
||||
|
||||
if ( alayer && alayer->exists( mDefinition ) )
|
||||
{
|
||||
mActionCreateAuxiliaryField->setEnabled( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
mActionCreateAuxiliaryField->setEnabled( true );
|
||||
}
|
||||
|
||||
bool fieldActive = false;
|
||||
if ( !mDataTypesString.isEmpty() )
|
||||
{
|
||||
@ -507,6 +524,10 @@ void QgsPropertyOverrideButton::menuActionTriggered( QAction *action )
|
||||
{
|
||||
showAssistant();
|
||||
}
|
||||
else if ( action == mActionCreateAuxiliaryField )
|
||||
{
|
||||
emit createAuxiliaryField();
|
||||
}
|
||||
else if ( mFieldsMenu->actions().contains( action ) ) // a field name clicked
|
||||
{
|
||||
if ( action->isEnabled() )
|
||||
|
@ -203,6 +203,9 @@ class GUI_EXPORT QgsPropertyOverrideButton: public QToolButton
|
||||
//! Emitted when the activated status of the widget changes
|
||||
void activated( bool isActive );
|
||||
|
||||
//! Emitted when creating a new auxiliary field
|
||||
void createAuxiliaryField();
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent( QMouseEvent *event ) override;
|
||||
|
||||
@ -246,6 +249,7 @@ class GUI_EXPORT QgsPropertyOverrideButton: public QToolButton
|
||||
QAction *mActionCopyExpr = nullptr;
|
||||
QAction *mActionClearExpr = nullptr;
|
||||
QAction *mActionAssistant = nullptr;
|
||||
QAction *mActionCreateAuxiliaryField = nullptr;
|
||||
|
||||
QgsPropertyDefinition mDefinition;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user