Skip to content
Permalink
Browse files

Merge pull request #6187 from DelazJ/rulebaseDialog

Show "Edit rule" dialog instead of widget when in Layer properties dialog
  • Loading branch information
elpaso committed Feb 19, 2018
2 parents d7edf6c + 3a6eac2 commit 6da78b9562486bb42a3260b05a887f5083fe20e4
@@ -181,12 +181,25 @@ void QgsRuleBasedRendererWidget::editRule( const QModelIndex &index )
return;

QgsRuleBasedRenderer::Rule *rule = mModel->ruleForIndex( index );
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );

if ( panel && panel->dockMode() )
{
QgsRendererRulePropsWidget *widget = new QgsRendererRulePropsWidget( rule, mLayer, mStyle, this, mContext );//panel?
widget->setPanelTitle( tr( "Edit Rule" ) );
connect( widget, &QgsPanelWidget::panelAccepted, this, &QgsRuleBasedRendererWidget::ruleWidgetPanelAccepted );
connect( widget, &QgsPanelWidget::widgetChanged, this, &QgsRuleBasedRendererWidget::liveUpdateRuleFromPanel );
openPanel( widget );
return;
}

QgsRendererRulePropsWidget *widget = new QgsRendererRulePropsWidget( rule, mLayer, mStyle, this, mContext );
widget->setPanelTitle( tr( "Edit Rule" ) );
connect( widget, &QgsPanelWidget::panelAccepted, this, &QgsRuleBasedRendererWidget::ruleWidgetPanelAccepted );
connect( widget, &QgsPanelWidget::widgetChanged, this, &QgsRuleBasedRendererWidget::liveUpdateRuleFromPanel );
openPanel( widget );
QgsRendererRulePropsDialog dlg( rule, mLayer, mStyle, this, mContext );
if ( dlg.exec() )
{
mModel->updateRule( index.parent(), index.row() );
mModel->clearFeatureCounts();
emit widgetChanged();
}
}

void QgsRuleBasedRendererWidget::removeRule()
@@ -666,23 +679,30 @@ QgsRendererRulePropsWidget::QgsRendererRulePropsWidget( QgsRuleBasedRenderer::Ru
connect( mScaleRangeWidget, &QgsScaleRangeWidget::rangeChanged, this, &QgsPanelWidget::widgetChanged );
}

#include "qgsvscrollarea.h"

QgsRendererRulePropsDialog::QgsRendererRulePropsDialog( QgsRuleBasedRenderer::Rule *rule, QgsVectorLayer *layer, QgsStyle *style, QWidget *parent, const QgsSymbolWidgetContext &context )
: QDialog( parent )
{

#ifdef Q_OS_MAC
setWindowModality( Qt::WindowModal );
#endif
this->setLayout( new QVBoxLayout() );

buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
QVBoxLayout *layout = new QVBoxLayout( this );
QgsVScrollArea *scrollArea = new QgsVScrollArea( this );
layout->addWidget( scrollArea );

buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
mPropsWidget = new QgsRendererRulePropsWidget( rule, layer, style, this, context );

this->layout()->addWidget( mPropsWidget );
this->layout()->addWidget( buttonBox );
scrollArea->setWidget( mPropsWidget );
layout->addWidget( buttonBox );
this->setWindowTitle( "Edit Rule" );

connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsRendererRulePropsDialog::accept );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsRendererRulePropsDialog::showHelp );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/QgsRendererRulePropsDialog/geometry" ) ).toByteArray() );
@@ -710,6 +730,11 @@ void QgsRendererRulePropsDialog::accept()
QDialog::accept();
}

void QgsRendererRulePropsDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "working_with_vector/vector_properties.html#rule-based-rendering" ) );
}


void QgsRendererRulePropsWidget::buildExpression()
{
@@ -273,6 +273,9 @@ class GUI_EXPORT QgsRendererRulePropsDialog : public QDialog
void buildExpression();
void accept() override;

private slots:
void showHelp();

private:
QgsRendererRulePropsWidget *mPropsWidget = nullptr;
QDialogButtonBox *buttonBox = nullptr;
@@ -6,134 +6,115 @@
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>274</height>
<width>376</width>
<height>155</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>407</width>
<height>254</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_1">
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="editLabel"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="editFilter"/>
</item>
<item>
<widget class="QPushButton" name="btnExpressionBuilder">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/themes/default/mIconExpression.svg</normaloff>:/images/themes/default/mIconExpression.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnTestFilter">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="editDescription"/>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_1">
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="editLabel"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupScale">
<property name="title">
<string>Scale range</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QgsScaleRangeWidget" name="mScaleRangeWidget" native="true">
<property name="toolTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLineEdit" name="editFilter"/>
</item>
<item>
<widget class="QGroupBox" name="groupSymbol">
<widget class="QPushButton" name="btnExpressionBuilder">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Symbol</string>
<property name="icon">
<iconset>
<normaloff>:/images/themes/default/mIconExpression.svg</normaloff>:/images/themes/default/mIconExpression.svg</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnTestFilter">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="editDescription"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupScale">
<property name="title">
<string>Scale range</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QgsScaleRangeWidget" name="mScaleRangeWidget" native="true">
<property name="toolTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupSymbol">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Symbol</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

0 comments on commit 6da78b9

Please sign in to comment.
You can’t perform that action at this time.