Skip to content
Permalink
Browse files

Use proper SQL code editor in filter preview widget in vector layer p…

…roperties

Gives proper syntax highlighting, matching bracket highlight, and correct
font/color scheme appearance
  • Loading branch information
nyalldawson committed Oct 16, 2020
1 parent c606cf8 commit 0f4270cfe600e77f09db7727bd3ba965be7acb0e
Showing with 13 additions and 17 deletions.
  1. +6 −4 src/gui/vector/qgsvectorlayerproperties.cpp
  2. +7 −13 src/ui/qgsvectorlayerpropertiesbase.ui
@@ -498,7 +498,9 @@ void QgsVectorLayerProperties::syncToLayer()
// using the query builder, either by typing it in by hand or using the buttons, etc
// on the builder. If the ability to enter a query directly into the box is required,
// a mechanism to check it must be implemented.
txtSubsetSQL->setEnabled( false );
txtSubsetSQL->setReadOnly( true );
txtSubsetSQL->setCaretWidth( 0 );
txtSubsetSQL->setCaretLineVisible( false );
setPbnQueryBuilderEnabled();

mMapTipWidget->setText( mLayer->mapTipTemplate() );
@@ -620,10 +622,10 @@ void QgsVectorLayerProperties::apply()
//
mSubsetGroupBox->setEnabled( true );

if ( txtSubsetSQL->toPlainText() != mLayer->subsetString() )
if ( txtSubsetSQL->text() != mLayer->subsetString() )
{
// set the subset sql for the layer
mLayer->setSubsetString( txtSubsetSQL->toPlainText() );
mLayer->setSubsetString( txtSubsetSQL->text() );
mMetadataFilled = false;
}
mOriginalSubsetSQL = mLayer->subsetString();
@@ -843,7 +845,7 @@ void QgsVectorLayerProperties::pbnQueryBuilder_clicked()

// Set the sql in the query builder to the same in the prop dialog
// (in case the user has already changed it)
qb->setSql( txtSubsetSQL->toPlainText() );
qb->setSql( txtSubsetSQL->text() );
// Open the query builder
if ( qb->exec() )
{
@@ -664,21 +664,9 @@ border-radius: 2px;</string>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QTextEdit" name="txtSubsetSQL">
<property name="enabled">
<bool>false</bool>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
<widget class="QgsCodeEditorSQL" name="txtSubsetSQL" native="true"/>
</item>
</layout>
<zorder>txtSubsetSQL</zorder>
<zorder>pbnQueryBuilder</zorder>
</widget>
</item>
<item>
@@ -2537,6 +2525,12 @@ border-radius: 2px;</string>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsCodeEditorSQL</class>
<extends>QWidget</extends>
<header>qgscodeeditorsql.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>

0 comments on commit 0f4270c

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