Skip to content
Permalink
Browse files
Update comments. Hide field value area
  • Loading branch information
NathanW2 committed Aug 10, 2011
1 parent f4c269a commit 24ff1cc467136036de9861c54b2cf04268798ef8
Showing with 38 additions and 34 deletions.
  1. +1 −1 src/app/qgslabelinggui.cpp
  2. +4 −4 src/core/qgspallabeling.cpp
  3. +1 −1 src/core/qgspallabeling.h
  4. +13 −9 src/gui/qgsexpressionbuilder.cpp
  5. +0 −10 src/gui/qgsexpressionbuilder.h
  6. +19 −9 src/ui/qgsexpressionbuilder.ui
@@ -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);
@@ -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;
@@ -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 ) )
@@ -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;
@@ -14,8 +14,6 @@
***************************************************************************/

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

#include "qgslogger.h"

QgsExpressionBuilderWidget::QgsExpressionBuilderWidget(QgsVectorLayer *layer)
@@ -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()
@@ -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)
@@ -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;
@@ -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
{
@@ -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">
@@ -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">
@@ -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">

0 comments on commit 24ff1cc

Please sign in to comment.