Navigation Menu

Skip to content

Commit

Permalink
Fix d&d designer expressions and drop not-used methods
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Apr 13, 2020
1 parent 1219d61 commit 47d6cb9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/core/qgseditformconfig.cpp
Expand Up @@ -639,8 +639,7 @@ QgsAttributeEditorElement *QgsEditFormConfig::attributeEditorElementFromDomEleme
newElement->setShowLabel( elem.attribute( QStringLiteral( "showLabel" ) ).toInt() );
else
newElement->setShowLabel( true );
if ( elem.hasAttribute( QStringLiteral( "labelExpression" ) ) )
newElement->setLabelExpression( elem.attribute( QStringLiteral( "labelExpression" ) ) );
newElement->setLabelExpression( labelExpression( newElement->name() ) );
}

return newElement;
Expand Down
10 changes: 6 additions & 4 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -1470,13 +1470,15 @@ void QgsAttributeForm::init()
}
else
{
if ( ! widgetInfo.labelExpression.isEmpty() )
{
mExpressionLabels[ label ] = QgsExpression( widgetInfo.labelExpression );
}
layout->addWidget( label, row, column++ );
layout->addWidget( widgetInfo.widget, row, column++ );
}

if ( ! widgetInfo.labelExpression.isEmpty() )
{
mExpressionLabels[ label ] = QgsExpression( widgetInfo.labelExpression );
}

}

if ( column >= columnCount * 2 )
Expand Down
17 changes: 1 addition & 16 deletions src/gui/vector/qgsattributesformproperties.cpp
Expand Up @@ -464,7 +464,6 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
{
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::Field, widgetDef->name(), widgetDef->name() );
itemData.setShowLabel( widgetDef->showLabel() );
itemData.setLabelExpression( widgetDef->labelExpression() );
newWidget = tree->addItem( parent, itemData );
break;
}
Expand All @@ -474,7 +473,6 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
const QgsAttributeEditorRelation *relationEditor = static_cast<const QgsAttributeEditorRelation *>( widgetDef );
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::Relation, relationEditor->relation().id(), relationEditor->relation().name() );
itemData.setShowLabel( widgetDef->showLabel() );
itemData.setLabelExpression( widgetDef->labelExpression() );
RelationEditorConfiguration relEdConfig;
relEdConfig.showLinkButton = relationEditor->showLinkButton();
relEdConfig.showUnlinkButton = relationEditor->showUnlinkButton();
Expand All @@ -493,7 +491,6 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
if ( !container )
break;

itemData.setLabelExpression( widgetDef->labelExpression() );
itemData.setColumnCount( container->columnCount() );
itemData.setShowAsGroupBox( container->isGroupBox() );
itemData.setBackgroundColor( container->backgroundColor() );
Expand All @@ -513,7 +510,6 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
const QgsAttributeEditorQmlElement *qmlElementEditor = static_cast<const QgsAttributeEditorQmlElement *>( widgetDef );
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::QmlWidget, widgetDef->name(), widgetDef->name() );
itemData.setShowLabel( widgetDef->showLabel() );
itemData.setLabelExpression( widgetDef->labelExpression() );
QmlElementEditorConfiguration qmlEdConfig;
qmlEdConfig.qmlCode = qmlElementEditor->qmlCode();
itemData.setQmlElementEditorConfiguration( qmlEdConfig );
Expand All @@ -526,7 +522,6 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
const QgsAttributeEditorHtmlElement *htmlElementEditor = static_cast<const QgsAttributeEditorHtmlElement *>( widgetDef );
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::HtmlWidget, widgetDef->name(), widgetDef->name() );
itemData.setShowLabel( widgetDef->showLabel() );
itemData.setLabelExpression( widgetDef->labelExpression() );
HtmlElementEditorConfiguration htmlEdConfig;
htmlEdConfig.htmlCode = htmlElementEditor->htmlCode();
itemData.setHtmlElementEditorConfiguration( htmlEdConfig );
Expand Down Expand Up @@ -703,6 +698,7 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid
{
int idx = mLayer->fields().lookupField( itemData.name() );
widgetDef = new QgsAttributeEditorField( itemData.name(), idx, parent );
widgetDef->setLabelExpression( mAttributeTypeDialog->aliasExpression() );
break;
}

Expand Down Expand Up @@ -758,7 +754,6 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid
}

widgetDef->setShowLabel( itemData.showLabel() );
widgetDef->setLabelExpression( itemData.labelExpression() );

return widgetDef;
}
Expand Down Expand Up @@ -1613,13 +1608,3 @@ void QgsAttributesFormProperties::DnDTreeItemData::setBackgroundColor( const QCo
mBackgroundColor = backgroundColor;
}

QString QgsAttributesFormProperties::DnDTreeItemData::labelExpression() const
{
return mLabelExpression;
}

void QgsAttributesFormProperties::DnDTreeItemData::setLabelExpression( const QString &labelExpression )
{
mLabelExpression = labelExpression;
}

7 changes: 1 addition & 6 deletions src/gui/vector/qgsattributesformproperties.h
Expand Up @@ -100,11 +100,10 @@ class GUI_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
//do we need that
DnDTreeItemData() = default;

DnDTreeItemData( Type type, const QString &name, const QString &displayName, const QColor &backgroundColor = QColor(), const QString &labelExpression = QString() )
DnDTreeItemData( Type type, const QString &name, const QString &displayName, const QColor &backgroundColor = QColor() )
: mType( type )
, mName( name )
, mDisplayName( displayName )
, mLabelExpression( labelExpression )
, mBackgroundColor( backgroundColor )
{}

Expand Down Expand Up @@ -143,14 +142,10 @@ class GUI_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
QColor backgroundColor() const;
void setBackgroundColor( const QColor &backgroundColor );

QString labelExpression() const;
void setLabelExpression( const QString &labelExpression );

private:
Type mType = Field;
QString mName;
QString mDisplayName;
QString mLabelExpression;
int mColumnCount = 1;
bool mShowAsGroupBox = false;
bool mShowLabel = true;
Expand Down

0 comments on commit 47d6cb9

Please sign in to comment.