Skip to content

Commit

Permalink
Expression builder: Rename Fields to Fields and Values; Add help for …
Browse files Browse the repository at this point in the history
…when field is selected
  • Loading branch information
NathanW2 committed Feb 1, 2012
1 parent 7dca9dd commit dd12b01
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
4 changes: 4 additions & 0 deletions resources/function_help/Field-en_US
@@ -0,0 +1,4 @@
<h3>Field</h3>
Double click to add field name to expression string.
<br><br>
Right-Click on field name to open context menu sample value loading options.
5 changes: 5 additions & 0 deletions resources/function_help/Fields and Values-en_US
@@ -0,0 +1,5 @@
<h3>Fields and Values</h3>
Contains a list of fields from the layer. Sample values can also be accessed via right-click.
<br><br>
Select the field name from the list then right-click to access context menu with options to load sample values from the selected field.

5 changes: 0 additions & 5 deletions resources/function_help/Fields-en_US

This file was deleted.

35 changes: 17 additions & 18 deletions src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -111,22 +111,16 @@ void QgsExpressionBuilderWidget::currentChanged( const QModelIndex &index, const

// Loading field values are handled with a
// right click so we just show the help.
if ( item->getItemType() == QgsExpressionItem::Field )
{
txtHelpText->setHtml( tr( "Double click to add field name to expression string. <br> "
"Or right click to select loading value options then "
"double click an item in the value list to add it to the expression string." ) );
txtHelpText->setToolTip( txtHelpText->toPlainText() );
}
else
if ( item->getItemType() != QgsExpressionItem::Field )
{
// Show the help for the current item.
mValueGroupBox->hide();
mValueListWidget->clear();
QString help = loadFunctionHelp( item );
txtHelpText->setText( help );
txtHelpText->setToolTip( txtHelpText->toPlainText() );

mValueGroupBox->hide();
mValueListWidget->clear();
}
// Show the help for the current item.
QString help = loadFunctionHelp( item );
txtHelpText->setText( help );
txtHelpText->setToolTip( txtHelpText->toPlainText() );
}

void QgsExpressionBuilderWidget::on_expressionTree_doubleClicked( const QModelIndex &index )
Expand Down Expand Up @@ -165,7 +159,7 @@ void QgsExpressionBuilderWidget::loadFieldNames( QgsFieldMap fields )
{
QString fieldName = field.name();
fieldNames << fieldName;
registerItem( tr( "Fields" ), fieldName, " \"" + fieldName + "\" ", "", QgsExpressionItem::Field );
registerItem( tr( "Fields and Values" ), fieldName, " \"" + fieldName + "\" ", "", QgsExpressionItem::Field );
}
highlighter->addFields( fieldNames );
}
Expand Down Expand Up @@ -243,7 +237,6 @@ void QgsExpressionBuilderWidget::on_txtExpressionString_textChanged()
lblPreview->setStyleSheet( "" );
txtExpressionString->setToolTip( "" );
lblPreview->setToolTip( "" );
// Return false for isValid because a null expression is still invalid.
emit expressionParsed( false );
return;
}
Expand Down Expand Up @@ -404,7 +397,13 @@ QString QgsExpressionBuilderWidget::loadFunctionHelp( QgsExpressionItem* functio
{
lang = "en_US";
}
QString fullHelpPath = helpFilesPath + functionName->text() + "-" + lang;

QString name = functionName->text();

if ( functionName->getItemType() == QgsExpressionItem::Field )
name = "Field";

QString fullHelpPath = helpFilesPath + name + "-" + lang;
// get the help content and title from the localized file
QString helpContents;
QFile file( fullHelpPath );
Expand All @@ -413,7 +412,7 @@ QString QgsExpressionBuilderWidget::loadFunctionHelp( QgsExpressionItem* functio
QString missingError = tr("<h3>Opps! QGIS can't find help for this function.</h3>"
"The help file for %1 was not found for your language<br>"
"If you would like to create it, contact the QGIS development team"
).arg( functionName->text() );
).arg( name );
if ( !file.exists() )
{
// change the file name to the en_US version (default)
Expand Down

0 comments on commit dd12b01

Please sign in to comment.