mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-10 00:04:23 -04:00
Fix for #7993 again, fields are listed twice in labeling data defined menu
- Reverts 0192e37 - Move code from init() to ctor for fix and to ensure connections are not duplicated - New code also fixes previously unknown issue when loading .qml style
This commit is contained in:
parent
5d68c30ef8
commit
a29f2ba5a1
@ -42,6 +42,51 @@ QgsDataDefinedButton::QgsDataDefinedButton( QWidget* parent,
|
|||||||
QString description )
|
QString description )
|
||||||
: QToolButton( parent )
|
: QToolButton( parent )
|
||||||
{
|
{
|
||||||
|
// set up static icons
|
||||||
|
if ( mIconDataDefine.isNull() )
|
||||||
|
{
|
||||||
|
mIconDataDefine = QgsApplication::getThemeIcon( "/mIconDataDefine.svg" );
|
||||||
|
mIconDataDefineOn = QgsApplication::getThemeIcon( "/mIconDataDefineOn.svg" );
|
||||||
|
mIconDataDefineError = QgsApplication::getThemeIcon( "/mIconDataDefineError.svg" );
|
||||||
|
mIconDataDefineExpression = QgsApplication::getThemeIcon( "/mIconDataDefineExpression.svg" );
|
||||||
|
mIconDataDefineExpressionOn = QgsApplication::getThemeIcon( "/mIconDataDefineExpressionOn.svg" );
|
||||||
|
mIconDataDefineExpressionError = QgsApplication::getThemeIcon( "/mIconDataDefineExpressionError.svg" );
|
||||||
|
}
|
||||||
|
|
||||||
|
// set default tool button icon properties
|
||||||
|
setFixedSize( 28, 24 );
|
||||||
|
setStyleSheet( QString( "QToolButton{ background: none; border: none;}" ) );
|
||||||
|
setIconSize( QSize( 24, 24 ) );
|
||||||
|
setPopupMode( QToolButton::InstantPopup );
|
||||||
|
|
||||||
|
mDefineMenu = new QMenu( this );
|
||||||
|
connect( mDefineMenu, SIGNAL( aboutToShow() ), this, SLOT( aboutToShowMenu() ) );
|
||||||
|
connect( mDefineMenu, SIGNAL( triggered( QAction* ) ), this, SLOT( menuActionTriggered( QAction* ) ) );
|
||||||
|
setMenu( mDefineMenu );
|
||||||
|
|
||||||
|
mFieldsMenu = new QMenu( this );
|
||||||
|
|
||||||
|
mActionDataTypes = new QAction( this );
|
||||||
|
// list fields and types in submenu, since there may be many
|
||||||
|
mActionDataTypes->setMenu( mFieldsMenu );
|
||||||
|
|
||||||
|
mActionActive = new QAction( this );
|
||||||
|
QFont f = mActionActive->font();
|
||||||
|
f.setBold( true );
|
||||||
|
mActionActive->setFont( f );
|
||||||
|
|
||||||
|
mActionDescription = new QAction( tr( "Description..." ), this );
|
||||||
|
|
||||||
|
mActionExpDialog = new QAction( tr( "Edit..." ), this );
|
||||||
|
mActionExpression = 0;
|
||||||
|
mActionPasteExpr = new QAction( tr( "Paste" ), this );
|
||||||
|
mActionCopyExpr = new QAction( tr( "Copy" ), this );
|
||||||
|
mActionClearExpr = new QAction( tr( "Clear" ), this );
|
||||||
|
|
||||||
|
// set up sibling widget connections
|
||||||
|
connect( this, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( disableEnabledWidgets( bool ) ) );
|
||||||
|
connect( this, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( checkCheckedWidgets( bool ) ) );
|
||||||
|
|
||||||
init( vl, datadefined, datatypes, description );
|
init( vl, datadefined, datatypes, description );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,49 +119,15 @@ void QgsDataDefinedButton::init( const QgsVectorLayer* vl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mDataTypes = datatypes;
|
mDataTypes = datatypes;
|
||||||
|
mFieldNameList.clear();
|
||||||
|
mFieldTypeList.clear();
|
||||||
|
|
||||||
mInputDescription = description;
|
mInputDescription = description;
|
||||||
mFullDescription = QString( "" );
|
mFullDescription = QString( "" );
|
||||||
mUsageInfo = QString( "" );
|
mUsageInfo = QString( "" );
|
||||||
mCurrentDefinition = QString( "" );
|
mCurrentDefinition = QString( "" );
|
||||||
|
|
||||||
mActionExpression = 0;
|
|
||||||
|
|
||||||
if ( mIconDataDefine.isNull() )
|
|
||||||
{
|
|
||||||
mIconDataDefine = QgsApplication::getThemeIcon( "/mIconDataDefine.svg" );
|
|
||||||
mIconDataDefineOn = QgsApplication::getThemeIcon( "/mIconDataDefineOn.svg" );
|
|
||||||
mIconDataDefineError = QgsApplication::getThemeIcon( "/mIconDataDefineError.svg" );
|
|
||||||
mIconDataDefineExpression = QgsApplication::getThemeIcon( "/mIconDataDefineExpression.svg" );
|
|
||||||
mIconDataDefineExpressionOn = QgsApplication::getThemeIcon( "/mIconDataDefineExpressionOn.svg" );
|
|
||||||
mIconDataDefineExpressionError = QgsApplication::getThemeIcon( "/mIconDataDefineExpressionError.svg" );
|
|
||||||
}
|
|
||||||
|
|
||||||
// set default icon properties
|
|
||||||
setFixedSize( 28, 24 );
|
|
||||||
setStyleSheet( QString( "QToolButton{ background: none; border: none;}" ) );
|
|
||||||
setIconSize( QSize( 24, 24 ) );
|
|
||||||
setPopupMode( QToolButton::InstantPopup );
|
|
||||||
|
|
||||||
mDefineMenu = new QMenu( this );
|
|
||||||
connect( mDefineMenu, SIGNAL( aboutToShow() ), this, SLOT( aboutToShowMenu() ) );
|
|
||||||
connect( mDefineMenu, SIGNAL( triggered( QAction* ) ), this, SLOT( menuActionTriggered( QAction* ) ) );
|
|
||||||
|
|
||||||
mFieldsMenu = new QMenu( this );
|
|
||||||
|
|
||||||
mActionActive = new QAction( this );
|
|
||||||
QFont f = mActionActive->font();
|
|
||||||
f.setBold( true );
|
|
||||||
mActionActive->setFont( f );
|
|
||||||
|
|
||||||
mActionDescription = new QAction( tr( "Description..." ), this );
|
|
||||||
|
|
||||||
mActionExpDialog = new QAction( tr( "Edit..." ), this );
|
|
||||||
mActionPasteExpr = new QAction( tr( "Paste" ), this );
|
|
||||||
mActionCopyExpr = new QAction( tr( "Copy" ), this );
|
|
||||||
mActionClearExpr = new QAction( tr( "Clear" ), this );
|
|
||||||
|
|
||||||
// set up data types string
|
// set up data types string
|
||||||
mActionDataTypes = 0;
|
|
||||||
mDataTypesString = QString( "" );
|
mDataTypesString = QString( "" );
|
||||||
|
|
||||||
QStringList ts;
|
QStringList ts;
|
||||||
@ -136,7 +147,7 @@ void QgsDataDefinedButton::init( const QgsVectorLayer* vl,
|
|||||||
if ( !ts.isEmpty() )
|
if ( !ts.isEmpty() )
|
||||||
{
|
{
|
||||||
mDataTypesString = ts.join( ", " );
|
mDataTypesString = ts.join( ", " );
|
||||||
mActionDataTypes = new QAction( tr( "Field type: " ) + mDataTypesString, this );
|
mActionDataTypes->setText( tr( "Field type: " ) + mDataTypesString );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mVectorLayer )
|
if ( mVectorLayer )
|
||||||
@ -176,12 +187,6 @@ void QgsDataDefinedButton::init( const QgsVectorLayer* vl,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setMenu( mDefineMenu );
|
|
||||||
|
|
||||||
// set up sibling widget connections
|
|
||||||
connect( this, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( disableEnabledWidgets( bool ) ) );
|
|
||||||
connect( this, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( checkCheckedWidgets( bool ) ) );
|
|
||||||
|
|
||||||
updateGui();
|
updateGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +248,7 @@ void QgsDataDefinedButton::aboutToShowMenu()
|
|||||||
|
|
||||||
mDefineMenu->addSeparator();
|
mDefineMenu->addSeparator();
|
||||||
|
|
||||||
if ( mActionDataTypes )
|
if ( !mDataTypesString.isEmpty() )
|
||||||
{
|
{
|
||||||
QAction* fieldTitleAct = mDefineMenu->addAction( tr( "Attribute field" ) );
|
QAction* fieldTitleAct = mDefineMenu->addAction( tr( "Attribute field" ) );
|
||||||
fieldTitleAct->setFont( titlefont );
|
fieldTitleAct->setFont( titlefont );
|
||||||
@ -274,9 +279,6 @@ void QgsDataDefinedButton::aboutToShowMenu()
|
|||||||
act->setEnabled( false );
|
act->setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// list fields and types in submenu, since there may be many
|
|
||||||
mActionDataTypes->setMenu( mFieldsMenu );
|
|
||||||
|
|
||||||
mDefineMenu->addSeparator();
|
mDefineMenu->addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,9 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton
|
|||||||
QMap< QString, QString > mProperty;
|
QMap< QString, QString > mProperty;
|
||||||
QList< QPointer<QWidget> > mEnabledWidgets;
|
QList< QPointer<QWidget> > mEnabledWidgets;
|
||||||
QList< QPointer<QWidget> > mCheckedWidgets;
|
QList< QPointer<QWidget> > mCheckedWidgets;
|
||||||
|
|
||||||
QMenu* mDefineMenu;
|
QMenu* mDefineMenu;
|
||||||
|
QAction* mActionDataTypes;
|
||||||
QMenu* mFieldsMenu;
|
QMenu* mFieldsMenu;
|
||||||
|
|
||||||
QAction* mActionActive;
|
QAction* mActionActive;
|
||||||
@ -260,7 +262,6 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton
|
|||||||
QAction* mActionPasteExpr;
|
QAction* mActionPasteExpr;
|
||||||
QAction* mActionCopyExpr;
|
QAction* mActionCopyExpr;
|
||||||
QAction* mActionClearExpr;
|
QAction* mActionClearExpr;
|
||||||
QAction* mActionDataTypes;
|
|
||||||
|
|
||||||
DataTypes mDataTypes;
|
DataTypes mDataTypes;
|
||||||
QString mDataTypesString;
|
QString mDataTypesString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user