Skip to content

Commit

Permalink
Update comments. Hide field value area
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Aug 10, 2011
1 parent f4c269a commit 24ff1cc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/app/qgslabelinggui.cpp
Expand Up @@ -488,7 +488,7 @@ void QgsLabelingGui::showExpressionDialog()
QDialog* dlg = new QDialog();
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
QGridLayout* layout = new QGridLayout();
QGridLayout* *layout = new QGridLayout();
QgsExpressionBuilderWidget* builder = new QgsExpressionBuilderWidget(mLayer);
dlg->setLayout(layout);
layout->addWidget(builder);
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgspallabeling.cpp
Expand Up @@ -456,13 +456,14 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
void QgsPalLayerSettings::registerFeature(QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context )
{
QString labelText;
// Check to see if we are a expression string.
if (isExpression)
{
QgsSearchString searchString;
// We don't do any validating here as we should only have a vaild expression at this point.
searchString.setString( fieldName );

QgsSearchTreeNode* searchTree = searchString.tree();
QgsSearchTreeNode* searchTree = searchString.tree();
if ( !searchTree )
{
return;
Expand All @@ -473,11 +474,10 @@ void QgsPalLayerSettings::registerFeature(QgsVectorLayer* layer, QgsFeature& f,

if (outValue.isError())
{
QgsDebugMsg("EXPRESSION ERROR = " + outValue.string());
QgsDebugMsg("Expression Label Error = " + outValue.string());
return;
}
QgsDebugMsg("EXPRESSION OUT VALUE = " + outValue.string());
labelText = outValue.string();
labelText = outValue.string();
}
else if ( formatNumbers == true && ( f.attributeMap()[fieldIndex].type() == QVariant::Int ||
f.attributeMap()[fieldIndex].type() == QVariant::Double ) )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspallabeling.h
Expand Up @@ -98,7 +98,7 @@ class CORE_EXPORT QgsPalLayerSettings
};

QString fieldName;
bool isExpression;
bool isExpression; // is this label made from a expression string eg FieldName || 'mm'
Placement placement;
unsigned int placementFlags;
QFont textFont;
Expand Down
22 changes: 13 additions & 9 deletions src/gui/qgsexpressionbuilder.cpp
Expand Up @@ -14,8 +14,6 @@
***************************************************************************/

#include "qgsexpressionbuilder.h"
#include "ui_qgsexpressionbuilder.h"

#include "qgslogger.h"

QgsExpressionBuilderWidget::QgsExpressionBuilderWidget(QgsVectorLayer *layer)
Expand All @@ -34,15 +32,18 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget(QgsVectorLayer *layer)
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("Operators","||"," || ","<b>|| (String Concatenation)</b> "/
"<br> Joins two values together into a string " /
"<br> <i>Usage:</i><br>'Dia' || Diameter");

this->registerItem("Geometry","Area"," $area ","<b>$area</b> <br> Returns the area the object. <br> Only applies to polygons.");
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","Y"," $y ");
this->registerItem("Geometry","XAt"," xat( ");
this->registerItem("Geometry","YAt"," yat( ");
}

QgsExpressionBuilderWidget::~QgsExpressionBuilderWidget()
Expand All @@ -53,7 +54,8 @@ QgsExpressionBuilderWidget::~QgsExpressionBuilderWidget()

void QgsExpressionBuilderWidget::on_mAllPushButton_clicked()
{

// We don't use this yet.
// TODO
}

void QgsExpressionBuilderWidget::on_expressionTree_clicked(const QModelIndex &index)
Expand All @@ -62,8 +64,10 @@ void QgsExpressionBuilderWidget::on_expressionTree_clicked(const QModelIndex &in
QgsExpressionItem* item = dynamic_cast<QgsExpressionItem*>(mModel->itemFromIndex(index));
if ( item == 0 )
return;


// Handle the special case for fields
// This is a bit hacky. Should be done better.
// This is a bit hacky. Should be done better. Handle it with a enum on QgsExpressionItem.
QStandardItem* parent = mModel->itemFromIndex(index.parent());
if ( parent == 0 )
return;
Expand Down
10 changes: 0 additions & 10 deletions src/gui/qgsexpressionbuilder.h
Expand Up @@ -23,16 +23,6 @@
#include "QStandardItemModel"
#include "QStandardItem"

//class QgsExpressionItem : public QStandardItem
//{
//public:
// QgsExpressionItem(QString label, QString expressionText);
// ~QgsExpressionItem();

// QString getExpressionText();
//private:
// QString mExpressionText;
//};

class QgsExpressionItem : public QStandardItem
{
Expand Down
28 changes: 19 additions & 9 deletions src/ui/qgsexpressionbuilder.ui
Expand Up @@ -75,7 +75,23 @@
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="mValueListWidget"/>
<widget class="QListWidget" name="mValueListWidget">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="viewMode">
<enum>QListView::ListMode</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
Expand All @@ -89,16 +105,10 @@
</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>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
Expand All @@ -113,7 +123,7 @@
<x>0</x>
<y>0</y>
<width>261</width>
<height>82</height>
<height>362</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
Expand Down

0 comments on commit 24ff1cc

Please sign in to comment.