Skip to content
Permalink
Browse files

Add signal for expression parsed in widget; fixed enabling of control…

…s in labeling gui; comments
  • Loading branch information
NathanW2 committed Oct 9, 2011
1 parent 107247e commit eb0642e0effabb3ebe661750f751b4a103013430
@@ -37,6 +37,8 @@
QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QWidget* parent )
: QDialog( parent ), mLBL( lbl ), mLayer( layer ), mMapCanvas( mapCanvas )
{
if ( !layer ) return;

setupUi( this );

connect( btnTextColor, SIGNAL( clicked() ), this, SLOT( changeTextColor() ) );
@@ -63,6 +65,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
Q_ASSERT( 0 && "NOOOO!" );
}

//mTabWidget->setEnabled( chkEnableLabeling->isChecked() );
chkMergeLines->setEnabled( layer->geometryType() == QGis::Line );
label_19->setEnabled( layer->geometryType() != QGis::Point );
mMinSizeSpinBox->setEnabled( layer->geometryType() != QGis::Point );
@@ -71,11 +74,16 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
QgsPalLayerSettings lyr;
lyr.readFromLayer( layer );
populateFieldNames();
populateDataDefinedCombos( lyr );

chkEnableLabeling->setChecked( lyr.enabled );
mTabWidget->setEnabled( lyr.enabled );
cboFieldName->setEnabled( lyr.enabled );
btnExpression->setEnabled( lyr.enabled );

//Add the current expression to the bottom of the list.
if (lyr.isExpression and !lyr.fieldName.isEmpty())
cboFieldName->addItem(lyr.fieldName);
populateDataDefinedCombos( lyr );

// placement
int distUnitIndex = lyr.distInMapUnits ? 1 : 0;
@@ -485,6 +493,8 @@ void QgsLabelingGui::showEngineConfigDialog()

void QgsLabelingGui::showExpressionDialog()
{
//TODO extract this out to a dialog.

QDialog* dlg = new QDialog();
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
@@ -495,6 +505,8 @@ void QgsLabelingGui::showExpressionDialog()
layout->addWidget(buttonBox);
connect(buttonBox,SIGNAL( accepted() ),dlg,SLOT( accept() ) );
connect(buttonBox,SIGNAL( rejected() ),dlg,SLOT( reject() ) );
QPushButton* okButuon = buttonBox->button(QDialogButtonBox::Ok);
connect(builder, SIGNAL(expressionParsed(bool)), okButuon, SLOT(setEnabled(bool)));

// Set the current expression using the selected text in the combo box.
builder->setExpressionString(this->cboFieldName->currentText());
@@ -188,10 +188,14 @@ void QgsExpressionBuilderWidget::on_txtExpressionString_textChanged()
if ( exp.hasParserError())
{
this->txtExpressionString->setStyleSheet("background-color: rgba(255, 6, 10, 75);");
this->txtExpressionString->setToolTip(exp.parserErrorString());
emit expressionParsed(false);
}
else
{
this->txtExpressionString->setStyleSheet("");
this->txtExpressionString->setToolTip("");
emit expressionParsed(true);
}
}

@@ -78,6 +78,7 @@ class QgsExpressionItem : public QStandardItem
QgsExpressionItem::ItemType mType;
};

/** A reusable widget that can be used to build a expression string. */
class QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExpressionBuilder {
Q_OBJECT
public:
@@ -107,7 +108,10 @@ class QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExpressionBuil
QString helpText = "",
QgsExpressionItem::ItemType type = QgsExpressionItem::ExpressionNode);

/** Does the expression used in the widget have any errors */
/** Does the expression used in the widget have any errors
* @note Users of this widget can check this to see if they should let the
* user move forward.
*/
bool hasExpressionError();

public slots:
@@ -116,6 +120,9 @@ public slots:
void on_expressionTree_doubleClicked(const QModelIndex &index);
void on_txtExpressionString_textChanged();

signals:
void expressionParsed(bool isVaild);

private:
void fillFieldValues(int fieldIndex, int countLimit);

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>589</width>
<height>604</height>
<width>533</width>
<height>591</height>
</rect>
</property>
<property name="windowTitle">
@@ -80,7 +80,7 @@
<item>
<widget class="QLabel" name="mValueListLabel">
<property name="text">
<string>Field Values</string>
<string>&lt;b&gt;Field Values&lt;/b&gt;</string>
</property>
</widget>
</item>
@@ -149,8 +149,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>277</width>
<height>140</height>
<width>249</width>
<height>127</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
@@ -187,8 +187,6 @@
</widget>
</item>
</layout>
<zorder>txtHelpText</zorder>
<zorder>scrollArea</zorder>
</widget>
</item>
</layout>
@@ -360,7 +358,7 @@
</size>
</property>
<property name="title">
<string>Expression =</string>
<string>Expression</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
@@ -79,7 +79,7 @@
</property>
<widget class="QWidget" name="tab_3">
<attribute name="icon">
<iconset>
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/propertyicons/labels.png</normaloff>:/images/themes/default/propertyicons/labels.png</iconset>
</attribute>
<attribute name="title">
@@ -390,7 +390,7 @@
</widget>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset>
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/propertyicons/general.png</normaloff>:/images/themes/default/propertyicons/general.png</iconset>
</attribute>
<attribute name="title">
@@ -856,7 +856,7 @@
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="icon">
<iconset>
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/gis/mActionOpenTable.png</normaloff>:/images/themes/gis/mActionOpenTable.png</iconset>
</attribute>
<attribute name="title">
@@ -1096,6 +1096,9 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
@@ -1180,32 +1183,32 @@
<connection>
<sender>chkEnableLabeling</sender>
<signal>clicked(bool)</signal>
<receiver>mTabWidget</receiver>
<receiver>cboFieldName</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>59</x>
<y>22</y>
<x>127</x>
<y>25</y>
</hint>
<hint type="destinationlabel">
<x>91</x>
<y>89</y>
<x>248</x>
<y>26</y>
</hint>
</hints>
</connection>
<connection>
<sender>chkEnableLabeling</sender>
<signal>clicked(bool)</signal>
<receiver>cboFieldName</receiver>
<receiver>mTabWidget</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>127</x>
<y>25</y>
<x>59</x>
<y>22</y>
</hint>
<hint type="destinationlabel">
<x>248</x>
<y>26</y>
<x>91</x>
<y>89</y>
</hint>
</hints>
</connection>

0 comments on commit eb0642e

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