Skip to content

Commit bad94e0

Browse files
committedSep 23, 2014
[expression builder] fixes #11247
1 parent 72a33ea commit bad94e0

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed
 

‎src/gui/qgscodeeditor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ void QgsCodeEditor::setFoldingVisible( bool folding )
106106
}
107107
}
108108

109+
void QgsCodeEditor::insertText( QString theText )
110+
{
111+
int line, index;
112+
getCursorPosition( &line, &index );
113+
insertAt( theText, line, index );
114+
setCursorPosition( line, index + theText.length() );
115+
}
116+
109117
// Settings for font and fontsize
110118
bool QgsCodeEditor::isFixedPitch( const QFont& font )
111119
{

‎src/gui/qgscodeeditor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class GUI_EXPORT QgsCodeEditor : public QsciScintilla
6060
void setFoldingVisible( bool folding );
6161
bool foldingVisible() { return mFolding; }
6262

63+
/** Isert text at cursor position
64+
* @param theText The text to be inserted
65+
*/
66+
void insertText( QString theText );
67+
6368
protected:
6469

6570
bool isFixedPitch( const QFont& font );

‎src/gui/qgsexpressionbuilderwidget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void QgsExpressionBuilderWidget::on_expressionTree_doubleClicked( const QModelIn
158158
return;
159159

160160
// Insert the expression text.
161-
txtExpressionString->insert( item->getExpressionText() );
161+
txtExpressionString->insertText( item->getExpressionText() );
162162
txtExpressionString->setFocus();
163163
}
164164

@@ -392,14 +392,14 @@ void QgsExpressionBuilderWidget::on_lblPreview_linkActivated( QString link )
392392

393393
void QgsExpressionBuilderWidget::on_mValueListWidget_itemDoubleClicked( QListWidgetItem *item )
394394
{
395-
txtExpressionString->insert( " " + item->text() + " " );
395+
txtExpressionString->insertText( " " + item->text() + " " );
396396
txtExpressionString->setFocus();
397397
}
398398

399399
void QgsExpressionBuilderWidget::operatorButtonClicked()
400400
{
401401
QPushButton* button = dynamic_cast<QPushButton*>( sender() );
402-
txtExpressionString->insert( " " + button->text() + " " );
402+
txtExpressionString->insertText( " " + button->text() + " " );
403403
txtExpressionString->setFocus();
404404
}
405405

0 commit comments

Comments
 (0)
Please sign in to comment.