Skip to content

Commit

Permalink
Merge pull request #1589 from slarosa/fix11247
Browse files Browse the repository at this point in the history
[expression builder] fixes #11247
  • Loading branch information
NathanW2 committed Sep 23, 2014
2 parents 72a33ea + bad94e0 commit d37f75f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/gui/qgscodeeditor.cpp
Expand Up @@ -106,6 +106,14 @@ void QgsCodeEditor::setFoldingVisible( bool folding )
}
}

void QgsCodeEditor::insertText( QString theText )
{
int line, index;
getCursorPosition( &line, &index );
insertAt( theText, line, index );
setCursorPosition( line, index + theText.length() );
}

// Settings for font and fontsize
bool QgsCodeEditor::isFixedPitch( const QFont& font )
{
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgscodeeditor.h
Expand Up @@ -60,6 +60,11 @@ class GUI_EXPORT QgsCodeEditor : public QsciScintilla
void setFoldingVisible( bool folding );
bool foldingVisible() { return mFolding; }

/** Isert text at cursor position
* @param theText The text to be inserted
*/
void insertText( QString theText );

protected:

bool isFixedPitch( const QFont& font );
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -158,7 +158,7 @@ void QgsExpressionBuilderWidget::on_expressionTree_doubleClicked( const QModelIn
return;

// Insert the expression text.
txtExpressionString->insert( item->getExpressionText() );
txtExpressionString->insertText( item->getExpressionText() );
txtExpressionString->setFocus();
}

Expand Down Expand Up @@ -392,14 +392,14 @@ void QgsExpressionBuilderWidget::on_lblPreview_linkActivated( QString link )

void QgsExpressionBuilderWidget::on_mValueListWidget_itemDoubleClicked( QListWidgetItem *item )
{
txtExpressionString->insert( " " + item->text() + " " );
txtExpressionString->insertText( " " + item->text() + " " );
txtExpressionString->setFocus();
}

void QgsExpressionBuilderWidget::operatorButtonClicked()
{
QPushButton* button = dynamic_cast<QPushButton*>( sender() );
txtExpressionString->insert( " " + button->text() + " " );
txtExpressionString->insertText( " " + button->text() + " " );
txtExpressionString->setFocus();
}

Expand Down

0 comments on commit d37f75f

Please sign in to comment.