Skip to content

Commit

Permalink
add button to show the help and values widget
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Dec 6, 2018
1 parent e77b124 commit 20da34a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
19 changes: 17 additions & 2 deletions src/gui/qgsexpressionbuilderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )

editorSplit->setSizes( QList<int>( {175, 300} ) );

functionsplit->setCollapsible( 0, false );
connect( mShowHelpButton, &QPushButton::clicked, this, [ = ]()
{
functionsplit->setSizes( QList<int>( {mOperationListGroup->width() - mHelpAndValuesWidget->minimumWidth(),
mHelpAndValuesWidget->minimumWidth()} ) );
mShowHelpButton->setEnabled( false );
} );
connect( functionsplit, &QSplitter::splitterMoved, this, [ = ]( int, int )
{
mShowHelpButton->setEnabled( functionsplit->sizes().at( 1 ) == 0 );
} );


QgsSettings settings;
splitter->restoreState( settings.value( QStringLiteral( "Windows/QgsExpressionBuilderWidget/splitter" ) ).toByteArray() );
editorSplit->restoreState( settings.value( QStringLiteral( "Windows/QgsExpressionBuilderWidget/editorsplitter" ) ).toByteArray() );
Expand Down Expand Up @@ -227,7 +240,9 @@ void QgsExpressionBuilderWidget::currentChanged( const QModelIndex &index, const
mValuesModel->setStringList( values );
}

mValueGroupBox->setVisible( item->getItemType() == QgsExpressionItem::Field && mLayer );
bool isField = mLayer && item->getItemType() == QgsExpressionItem::Field;
mValueGroupBox->setVisible( isField );
mShowHelpButton->setText( isField ? tr( "Show Values" ) : tr( "Show Help" ) );

// Show the help for the current item.
QString help = loadFunctionHelp( item );
Expand Down Expand Up @@ -1092,7 +1107,7 @@ void QgsExpressionBuilderWidget::indicatorClicked( int line, int index, Qt::Keyb
if ( state & Qt::ControlModifier )
{
int position = txtExpressionString->positionFromLineIndex( line, index );
long fncIndex = txtExpressionString->SendScintilla( QsciScintilla::SCI_INDICATORVALUEAT, FUNCTION_MARKER_ID, ( long int )position );
long fncIndex = txtExpressionString->SendScintilla( QsciScintilla::SCI_INDICATORVALUEAT, FUNCTION_MARKER_ID, static_cast<long int>( position ) );
QgsExpressionFunction *func = QgsExpression::Functions()[fncIndex];
QString help = getFunctionHelp( func );
txtHelpText->setText( help );
Expand Down
53 changes: 18 additions & 35 deletions src/ui/qgsexpressionbuilder.ui
Original file line number Diff line number Diff line change
Expand Up @@ -447,23 +447,30 @@
</item>
</layout>
</widget>
<widget class="QFrame" name="moperationListGroup">
<widget class="QFrame" name="mOperationListGroup">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QSplitter" name="functionsplit">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget1">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QgsFilterLineEdit" name="txtSearchEdit">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QPushButton" name="mShowHelpButton">
<property name="text">
<string>Show Help</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QTreeView" name="expressionTree">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
Expand All @@ -490,7 +497,13 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget2">
<widget class="QWidget" name="mHelpAndValuesWidget" native="true">
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
Expand Down Expand Up @@ -824,36 +837,6 @@ Saved scripts are auto loaded on QGIS startup.</string>
</customwidgets>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit 20da34a

Please sign in to comment.