Skip to content
Permalink
Browse files
Use code editor for expression widget
  • Loading branch information
NathanW2 committed Jul 16, 2014
1 parent 32dfb86 commit 93fb9dbfdc3205adfa5f484b7edf3e828ea4e8e7
Showing with 19 additions and 44 deletions.
  1. +1 −0 src/gui/qgscodeeditor.cpp
  2. +0 −7 src/gui/qgscodeeditorpython.cpp
  3. +8 −8 src/gui/qgsexpressionbuilderwidget.cpp
  4. +10 −29 src/ui/qgsexpressionbuilder.ui
@@ -36,6 +36,7 @@ QgsCodeEditor::QgsCodeEditor( QWidget *parent, QString title, bool folding, bool
setWindowTitle( mWidgetTitle );
}
setSciWidget();
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
}

QgsCodeEditor::~QgsCodeEditor()
@@ -132,13 +132,6 @@ void QgsCodeEditorPython::loadScript( const QString &script )

QTextStream in( &file );

//QString line = in.readAll();
//while ( !in.atEnd() )
//{
//QString line = in.readLine();
//QStringList fields = line.split( "," );
//QgsCodeEditor::insert( fields );
//}
setText( in.readAll() );
file.close();

@@ -32,7 +32,7 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )

mValueGroupBox->hide();
mLoadGroupBox->hide();
highlighter = new QgsExpressionHighlighter( txtExpressionString->document() );
// highlighter = new QgsExpressionHighlighter( txtExpressionString->document() );

mModel = new QStandardItemModel( );
mProxyModel = new QgsExpressionItemSearchProxy();
@@ -158,7 +158,7 @@ void QgsExpressionBuilderWidget::on_expressionTree_doubleClicked( const QModelIn
return;

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

@@ -185,7 +185,7 @@ void QgsExpressionBuilderWidget::loadFieldNames( const QgsFields& fields )
fieldNames << fieldName;
registerItem( "Fields and Values", fieldName, " \"" + fieldName + "\" ", "", QgsExpressionItem::Field );
}
highlighter->addFields( fieldNames );
// highlighter->addFields( fieldNames );
}

void QgsExpressionBuilderWidget::fillFieldValues( int fieldIndex, int countLimit )
@@ -289,17 +289,17 @@ void QgsExpressionBuilderWidget::setGeomCalculator( const QgsDistanceArea & da )

QString QgsExpressionBuilderWidget::expressionText()
{
return txtExpressionString->toPlainText();
return txtExpressionString->text();
}

void QgsExpressionBuilderWidget::setExpressionText( const QString& expression )
{
txtExpressionString->setPlainText( expression );
txtExpressionString->setText( expression );
}

void QgsExpressionBuilderWidget::on_txtExpressionString_textChanged()
{
QString text = txtExpressionString->toPlainText();
QString text = txtExpressionString->text();

// If the string is empty the expression will still "fail" although
// we don't show the user an error as it will be confusing.
@@ -392,14 +392,14 @@ void QgsExpressionBuilderWidget::on_lblPreview_linkActivated( QString link )

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

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

@@ -441,37 +441,9 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QTextEdit" name="txtExpressionString">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="cursor" stdset="0">
<cursorShape>IBeamCursor</cursorShape>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
@@ -533,6 +505,9 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QgsCodeEditorSQL" name="txtExpressionString" native="true"/>
</item>
</layout>
</widget>
</item>
@@ -554,6 +529,12 @@
<extends>QLineEdit</extends>
<header>qgsfilterlineedit.h</header>
</customwidget>
<customwidget>
<class>QgsCodeEditorSQL</class>
<extends>QWidget</extends>
<header>qgscodeeditorsql.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

0 comments on commit 93fb9db

Please sign in to comment.