Skip to content

Commit

Permalink
[expression builder] fixes #11247
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed Sep 23, 2014
1 parent 72a33ea commit bad94e0
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 bad94e0

Please sign in to comment.