Skip to content
Permalink
Browse files

Added support to show help about selected function

  • Loading branch information
NathanW2 committed Jul 13, 2011
1 parent 439a711 commit 74545848cb5d46518d58f79dc806d7c1ad7130be
Showing with 127 additions and 15 deletions.
  1. +15 −6 src/gui/qgsexpressionbuilder.cpp
  2. +12 −3 src/gui/qgsexpressionbuilder.h
  3. +100 −6 src/ui/qgsexpressionbuilder.ui
@@ -32,14 +32,17 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget(QgsVectorLayer *layer)
this->registerItem("Operators","-"," -");
this->registerItem("Operators","*"," * ");
this->registerItem("Operators","/"," / ");
this->registerItem("Operators","^"," ^ ");
this->registerItem("Operators","="," = ");
this->registerItem("Operators","||"," || ","<b>|| (String Concatenation)</b> <br> Concats two values together into a string <br> <i>Usage:</i><br>'Dia' || Diameter");

this->registerItem("Geometry","Area"," $area ");
this->registerItem("Geometry","Length"," $length ");
this->registerItem("Geometry","Area"," $area ","<b>$area</b> <br> Returns the area the object. <br> Only applies to polygons.");
this->registerItem("Geometry","Length"," $length ","<b>$length</b> <br> Returns the length the object. <br> Only applies to polylines.");
this->registerItem("Geometry","Perimeter"," $perimeter ");
this->registerItem("Geometry","X"," $x ");
this->registerItem("Geometry","Y"," $y ");
this->registerItem("Geometry","XAt"," xat() ");
this->registerItem("Geometry","YAt"," yat() ");
this->registerItem("Geometry","XAt"," xat( ");
this->registerItem("Geometry","YAt"," yat( ");
}

QgsExpressionBuilderWidget::~QgsExpressionBuilderWidget()
@@ -72,8 +75,9 @@ void QgsExpressionBuilderWidget::on_expressionTree_clicked(const QModelIndex &in
}
else
{
// We might be able to show help for the current selected item here.
// Show the help for the current item.
mValueListWidget->clear();
txtHelpText->setText(item->getHelpText());
}
}

@@ -124,7 +128,12 @@ void QgsExpressionBuilderWidget::fillFieldValues(int fieldIndex, int countLimit)

void QgsExpressionBuilderWidget::registerItem(QString group, QString label, QString expressionText)
{
QgsExpressionItem* item = new QgsExpressionItem(label,expressionText);
this->registerItem(group,label,expressionText,"");
}

void QgsExpressionBuilderWidget::registerItem(QString group, QString label, QString expressionText, QString helpText)
{
QgsExpressionItem* item = new QgsExpressionItem(label,expressionText, helpText);
// Look up the group and insert the new function.
if (mExpressionGroups.contains(group))
{
@@ -37,18 +37,26 @@
class QgsExpressionItem : public QStandardItem
{
public:
QgsExpressionItem(QString label, QString expressionText)
QgsExpressionItem(QString label, QString expressionText, QString helpText)
: QStandardItem(label)
{
mExpressionText = expressionText;
mHelpText = helpText;
}

QString getExpressionText()
QgsExpressionItem(QString label, QString expressionText)
: QStandardItem(label)
{
return mExpressionText;
mExpressionText = expressionText;
}

QString getExpressionText() { return mExpressionText; }

QString getHelpText() { return mHelpText; }

private:
QString mExpressionText;
QString mHelpText;
};

class QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExpressionBuilder {
@@ -62,6 +70,7 @@ class QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExpressionBuil
QString getExpressionString();
void setExpressionString(const QString expressionString);
void registerItem(QString group, QString label, QString expressionText);
void registerItem(QString group, QString label, QString expressionText, QString helpText);

public slots:
void on_mAllPushButton_clicked();
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<height>452</height>
<width>538</width>
<height>615</height>
</rect>
</property>
<property name="windowTitle">
@@ -23,7 +23,16 @@
<string>Operation List</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
@@ -55,7 +64,83 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QListWidget" name="mValueListWidget"/>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="mValueListWidget"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Function Help</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>300</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>261</width>
<height>82</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="txtHelpText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>fsbn</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@@ -108,7 +193,16 @@
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -222,7 +316,7 @@
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>4</number>
</property>
<property name="rightMargin">
<number>0</number>

0 comments on commit 7454584

Please sign in to comment.
You can’t perform that action at this time.