Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 0f4270c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
10 changes: 6 additions & 4 deletions src/gui/vector/qgsvectorlayerproperties.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() )
{
Expand Down
20 changes: 7 additions & 13 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 0f4270c

Please sign in to comment.