Skip to content

Commit 65b978f

Browse files
committedAug 28, 2012
[FEATURE] add optional filter value to value relation edit widget
and sync QgsVectorLayer sip bindings with C++ interface
1 parent b9ae061 commit 65b978f

File tree

7 files changed

+906
-732
lines changed

7 files changed

+906
-732
lines changed
 

‎python/core/qgsvectorlayer.sip

Lines changed: 675 additions & 632 deletions
Large diffs are not rendered by default.

‎src/app/qgsattributetypedialog.cpp

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl )
5252
}
5353

5454
connect( valueRelationLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateLayerColumns( int ) ) );
55+
connect( valueRelationFilterColumn, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateFilterColumn( int ) ) );
5556
valueRelationLayer->setCurrentIndex( -1 );
5657
}
5758

@@ -606,6 +607,16 @@ void QgsAttributeTypeDialog::accept()
606607
mValueRelationData.mAllowNull = valueRelationAllowNull->isChecked();
607608
mValueRelationData.mOrderByValue = valueRelationOrderByValue->isChecked();
608609
mValueRelationData.mAllowMulti = valueRelationAllowMulti->isChecked();
610+
if( valueRelationFilterColumn->currentIndex() == 0 )
611+
{
612+
mValueRelationData.mFilterAttributeColumn = QString::null;
613+
mValueRelationData.mFilterAttributeValue = QString::null;
614+
}
615+
else
616+
{
617+
mValueRelationData.mFilterAttributeColumn = valueRelationFilterColumn->currentText();
618+
mValueRelationData.mFilterAttributeValue = valueRelationFilterValue->currentText();
619+
}
609620
break;
610621
case 13:
611622
mEditType = QgsVectorLayer::UuidGenerator;
@@ -631,12 +642,51 @@ void QgsAttributeTypeDialog::updateLayerColumns( int idx )
631642
if ( !vl )
632643
return;
633644

634-
foreach ( const QgsField &f, vl->pendingFields() )
645+
valueRelationFilterColumn->addItem( tr( "No filter" ), -1 );
646+
647+
const QgsFieldMap &fields = vl->pendingFields();
648+
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
635649
{
636-
valueRelationKeyColumn->addItem( f.name() );
637-
valueRelationValueColumn->addItem( f.name() );
650+
valueRelationKeyColumn->addItem( it->name() );
651+
valueRelationValueColumn->addItem( it->name() );
652+
valueRelationFilterColumn->addItem( it->name(), it.key() );
638653
}
639654

640655
valueRelationKeyColumn->setCurrentIndex( valueRelationKeyColumn->findText( mValueRelationData.mKey ) );
641656
valueRelationValueColumn->setCurrentIndex( valueRelationValueColumn->findText( mValueRelationData.mValue ) );
657+
658+
if( mValueRelationData.mFilterAttributeColumn.isNull() )
659+
{
660+
valueRelationFilterColumn->setCurrentIndex( 0 );
661+
}
662+
else
663+
{
664+
valueRelationFilterColumn->setCurrentIndex( valueRelationFilterColumn->findText( mValueRelationData.mFilterAttributeColumn ) );
665+
}
666+
}
667+
668+
void QgsAttributeTypeDialog::updateFilterColumn( int idx )
669+
{
670+
valueRelationFilterValue->clear();
671+
valueRelationFilterValue->setEnabled( idx > 0 );
672+
if ( idx == 0 )
673+
return;
674+
675+
QString id = valueRelationLayer->itemData( valueRelationLayer->currentIndex() ).toString();
676+
677+
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( id ) );
678+
if ( !vl )
679+
return;
680+
681+
int fidx = valueRelationFilterColumn->itemData( idx ).toInt();
682+
683+
QList<QVariant> uniqueValues;
684+
vl->uniqueValues( fidx, uniqueValues );
685+
686+
foreach( const QVariant &v, uniqueValues )
687+
{
688+
valueRelationFilterValue->addItem( v.toString(), v );
689+
}
690+
691+
valueRelationFilterValue->setCurrentIndex( valueRelationFilterValue->findText( mValueRelationData.mFilterAttributeValue ) );
642692
}

‎src/app/qgsattributetypedialog.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
139139
*/
140140
void updateLayerColumns( int idx );
141141

142+
/**
143+
* update filter value list
144+
*/
145+
void updateFilterColumn( int idx );
146+
142147
private:
143148

144149
QString defaultWindowTitle();

‎src/core/qgsvectorlayer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3160,7 +3160,9 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
31603160
bool allowNull = editTypeElement.attribute( "allowNull" ) == "true";
31613161
bool orderByValue = editTypeElement.attribute( "orderByValue" ) == "true";
31623162
bool allowMulti = editTypeElement.attribute( "allowMulti", "false" ) == "true";
3163-
mValueRelations[ name ] = ValueRelationData( id, key, value, allowNull, orderByValue, allowMulti );
3163+
QString filterAttributeColumn= editTypeElement.attribute( "filterAttributeColumn", QString::null );
3164+
QString filterAttributeValue = editTypeElement.attribute( "filterAttributeValue", QString::null );
3165+
mValueRelations[ name ] = ValueRelationData( id, key, value, allowNull, orderByValue, allowMulti, filterAttributeColumn, filterAttributeValue );
31643166
}
31653167
break;
31663168

@@ -3382,6 +3384,10 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
33823384
editTypeElement.setAttribute( "allowNull", data.mAllowNull ? "true" : "false" );
33833385
editTypeElement.setAttribute( "orderByValue", data.mOrderByValue ? "true" : "false" );
33843386
editTypeElement.setAttribute( "allowMulti", data.mAllowMulti ? "true" : "false" );
3387+
if ( !data.mFilterAttributeColumn.isNull() )
3388+
editTypeElement.setAttribute( "filterAttributeColumn", data.mFilterAttributeColumn );
3389+
if ( !data.mFilterAttributeValue.isNull() )
3390+
editTypeElement.setAttribute( "filterAttributeValue", data.mFilterAttributeValue );
33853391
}
33863392
break;
33873393

‎src/core/qgsvectorlayer.h

Lines changed: 81 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ struct CORE_EXPORT QgsVectorJoinInfo
6464
int joinField;
6565
/**True if the join is cached in virtual memory*/
6666
bool memoryCache;
67-
/**Cache for joined attributes to provide fast lookup (size is 0 if no memory caching)*/
67+
/**Cache for joined attributes to provide fast lookup (size is 0 if no memory caching)
68+
@note not available in python bindings
69+
*/
6870
QHash< QString, QgsAttributeMap> cachedAttributes;
6971
};
7072

@@ -99,7 +101,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
99101
CheckBox, /* added in 1.4 */
100102
FileName,
101103
Enumeration,
102-
Immutable, /* The attribute value should not be changed in the attribute form*/
104+
Immutable, /* The attribute value should not be changed in the attribute form */
103105
Hidden, /* The attribute value should not be shown in the attribute form @added in 1.4 */
104106
TextEdit, /* multiline edit @added in 1.4*/
105107
Calendar, /* calendar widget @added in 1.5 */
@@ -122,12 +124,25 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
122124
struct ValueRelationData
123125
{
124126
ValueRelationData() {}
125-
ValueRelationData( QString layer, QString key, QString value, bool allowNull, bool orderByValue, bool allowMulti = false )
126-
: mLayer( layer ), mKey( key ), mValue( value ), mAllowNull( allowNull ), mOrderByValue( orderByValue ), mAllowMulti( allowMulti ) {}
127+
ValueRelationData( QString layer, QString key, QString value, bool allowNull, bool orderByValue,
128+
bool allowMulti = false,
129+
QString filterAttributeColumn = QString::null,
130+
QString filterAttributeValue = QString::null )
131+
: mLayer( layer )
132+
, mKey( key )
133+
, mValue( value )
134+
, mFilterAttributeColumn( filterAttributeColumn )
135+
, mFilterAttributeValue( filterAttributeValue )
136+
, mAllowNull( allowNull )
137+
, mOrderByValue( orderByValue )
138+
, mAllowMulti( allowMulti )
139+
{}
127140

128141
QString mLayer;
129142
QString mKey;
130143
QString mValue;
144+
QString mFilterAttributeColumn;
145+
QString mFilterAttributeValue;
131146
bool mAllowNull;
132147
bool mOrderByValue;
133148
bool mAllowMulti; /* allow selection of multiple keys @added in 1.9 */
@@ -158,7 +173,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
158173
/** Returns the data provider */
159174
QgsVectorDataProvider* dataProvider();
160175

161-
/** Returns the data provider in a const-correct manner */
176+
/** Returns the data provider in a const-correct manner
177+
@note not available in python bindings
178+
*/
162179
const QgsVectorDataProvider* dataProvider() const;
163180

164181
/** Sets the textencoding of the data provider */
@@ -184,7 +201,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
184201

185202
const QgsLabel *label() const;
186203

187-
QgsAttributeAction* actions() { return mActions; }
204+
QgsAttributeAction *actions() { return mActions; }
188205

189206
/** The number of features that are selected in this layer */
190207
int selectedFeatureCount();
@@ -202,10 +219,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
202219
QgsFeatureList selectedFeatures();
203220

204221
/** Return reference to identifiers of selected features */
205-
const QgsFeatureIds& selectedFeaturesIds() const;
222+
const QgsFeatureIds &selectedFeaturesIds() const;
206223

207224
/** Change selection to the new set of features */
208-
void setSelectedFeatures( const QgsFeatureIds& ids );
225+
void setSelectedFeatures( const QgsFeatureIds &ids );
209226

210227
/** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */
211228
QgsRectangle boundingBoxOfSelected();
@@ -259,7 +276,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
259276
QGis::GeometryType geometryType() const;
260277

261278
/** Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry
262-
@note added in 1.7*/
279+
* @note added in 1.7
280+
*/
263281
bool hasGeometryType() const;
264282

265283
/**Returns the WKBType or WKBUnknown in case of error*/
@@ -279,10 +297,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
279297
virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc );
280298

281299
/** Read the symbology for the current layer from the Dom node supplied.
282-
* @param node node that will contain the symbology definition for this layer.
283-
* @param errorMessage reference to string that will be updated with any error messages
284-
* @return true in case of success.
285-
*/
300+
* @param node node that will contain the symbology definition for this layer.
301+
* @param errorMessage reference to string that will be updated with any error messages
302+
* @return true in case of success.
303+
*/
286304
bool readSymbology( const QDomNode& node, QString& errorMessage );
287305

288306
/** Write the symbology for the layer into the docment provided.
@@ -308,7 +326,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
308326
/** This function does nothing useful, it's kept only for compatibility.
309327
* @todo to be removed
310328
*/
311-
virtual long updateFeatureCount() const;
329+
Q_DECL_DEPRECATED virtual long updateFeatureCount() const;
312330

313331
/**
314332
* Set the string (typically sql) used to define a subset of the layer
@@ -413,37 +431,42 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
413431
int translateFeature( QgsFeatureId featureId, double dx, double dy );
414432

415433
/**Splits features cut by the given line
416-
@param splitLine line that splits the layer features
417-
@param topologicalEditing true if topological editing is enabled
418-
@return 0 in case of success, 4 if there is a selection but no feature split*/
434+
* @param splitLine line that splits the layer features
435+
* @param topologicalEditing true if topological editing is enabled
436+
* @return
437+
* 0 in case of success,
438+
* 4 if there is a selection but no feature split
439+
*/
419440
int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
420441

421442
/**Changes the specified geometry such that it has no intersections with other
422-
polygon (or multipolygon) geometries in this vector layer
423-
@param geom geometry to modify
424-
@return 0 in case of success*/
443+
* polygon (or multipolygon) geometries in this vector layer
444+
* @param geom geometry to modify
445+
* @return 0 in case of success
446+
*/
425447
int removePolygonIntersections( QgsGeometry* geom );
426448

427449
/** Adds topological points for every vertex of the geometry.
428-
@param geom the geometry where each vertex is added to segments of other features
429-
@note geom is not going to be modified by the function
430-
@return 0 in case of success
431-
@see addTopologicalPoints
432-
*/
450+
* @param geom the geometry where each vertex is added to segments of other features
451+
* @note geom is not going to be modified by the function
452+
* @return 0 in case of success
453+
*/
433454
int addTopologicalPoints( QgsGeometry* geom );
434455

435-
/**Adds a vertex to segments which intersect point p but don't
436-
already have a vertex there. If a feature already has a vertex at position p,
437-
no additional vertex is inserted. This method is useful for topological
438-
editing.
439-
@param p position of the vertex
440-
@return 0 in case of success*/
456+
/** Adds a vertex to segments which intersect point p but don't
457+
* already have a vertex there. If a feature already has a vertex at position p,
458+
* no additional vertex is inserted. This method is useful for topological
459+
* editing.
460+
* @param p position of the vertex
461+
* @return 0 in case of success
462+
*/
441463
int addTopologicalPoints( const QgsPoint& p );
442464

443465
/**Inserts vertices to the snapped segments.
444-
This is useful for topological editing if snap to segment is enabled.
445-
@param snapResults results collected from the snapping operation
446-
@return 0 in case of success*/
466+
* This is useful for topological editing if snap to segment is enabled.
467+
* @param snapResults results collected from the snapping operation
468+
* @return 0 in case of success
469+
*/
447470
int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
448471

449472
/** Set labels on */
@@ -456,26 +479,28 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
456479
virtual bool isEditable() const;
457480

458481
/** Returns true if the provider is in read-only mode
459-
* @note added in 1.6 */
482+
* @note added in 1.6
483+
*/
460484
virtual bool isReadOnly() const;
461485

462486
/** Returns true if the provider has been modified since the last commit */
463487
virtual bool isModified() const;
464488

465489
/**Snaps a point to the closest vertex if there is one within the snapping tolerance
466-
@param point The point which is set to the position of a vertex if there is one within the snapping tolerance.
467-
If there is no point within this tolerance, point is left unchanged.
468-
@param tolerance The snapping tolerance
469-
@return true if point has been snapped, false if no vertex within search tolerance*/
490+
* @param point The point which is set to the position of a vertex if there is one within the snapping tolerance.
491+
* If there is no point within this tolerance, point is left unchanged.
492+
* @param tolerance The snapping tolerance
493+
* @return true if the point has been snapped, false if no vertex within search tolerance
494+
*/
470495
bool snapPoint( QgsPoint& point, double tolerance );
471496

472497
/**Snaps to segment or vertex within given tolerance
473-
@param startPoint point to snap (in layer coordinates)
474-
@param snappingTolerance distance tolerance for snapping
475-
@param snappingResults snapping results. Key is the distance between startPoint and snapping target
476-
@param snap_to to segment / to vertex
477-
@return 0 in case of success
478-
*/
498+
* @param startPoint point to snap (in layer coordinates)
499+
* @param snappingTolerance distance tolerance for snapping
500+
* @param snappingResults snapping results. Key is the distance between startPoint and snapping target
501+
* @param snap_to to segment / to vertex
502+
* @return 0 in case of success
503+
*/
479504
int snapWithContext( const QgsPoint& startPoint,
480505
double snappingTolerance,
481506
QMultiMap < double, QgsSnappingResult > &snappingResults,
@@ -585,7 +610,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
585610
/** set string representing 'true' for a checkbox (added in 1.4) */
586611
void setCheckedState( int idx, QString checked, QString notChecked );
587612

588-
/** return string representing 'true' for a checkbox (added in 1.4) */
613+
/** return string representing 'true' for a checkbox (added in 1.4)
614+
* @note not available in python bindings
615+
*/
589616
QPair<QString, QString> checkedState( int idx );
590617

591618
/** get edit form (added in 1.4) */
@@ -650,10 +677,14 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
650677
/** Destroy active command and reverts all changes in it */
651678
void destroyEditCommand();
652679

653-
/** Execute undo operation. To be called only from QgsVectorLayerUndoCommand. */
680+
/** Execute undo operation. To be called only from QgsVectorLayerUndoCommand.
681+
* @note not available in python bindings
682+
*/
654683
void undoEditCommand( QgsUndoCommand* cmd );
655684

656-
/** Execute redo operation. To be called only from QgsVectorLayerUndoCommand. */
685+
/** Execute redo operation. To be called only from QgsVectorLayerUndoCommand.
686+
* @note not available in python bindings
687+
*/
657688
void redoEditCommand( QgsUndoCommand* cmd );
658689

659690
/** Returns the index of a field name or -1 if the field does not exist
@@ -690,7 +721,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
690721
void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
691722

692723
/**Returns minimum value for an attribute column or invalid variant in case of error
693-
@note added in 1.7*/
724+
@note added in 1.7*/
694725
QVariant minimumValue( int index );
695726

696727
/**Returns maximum value for an attribute column or invalid variant in case of error
@@ -755,7 +786,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
755786
private: // Private methods
756787

757788
/** vector layers are not copyable */
758-
QgsVectorLayer( QgsVectorLayer const & rhs );
789+
QgsVectorLayer( const QgsVectorLayer & rhs );
759790

760791
/** vector layers are not copyable */
761792
QgsVectorLayer & operator=( QgsVectorLayer const & rhs );

‎src/gui/qgsattributeeditor.cpp

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ void QgsAttributeEditor::selectFileName()
6262
if ( fileName.isNull() )
6363
return;
6464

65-
//le->setText( fileName );
6665
le->setText( QDir::toNativeSeparators( fileName ) );
6766
}
6867

@@ -104,7 +103,7 @@ void QgsAttributeEditor::selectDate()
104103

105104
QComboBox *QgsAttributeEditor::comboBox( QWidget *editor, QWidget *parent )
106105
{
107-
QComboBox *cb = NULL;
106+
QComboBox *cb = 0;
108107
if ( editor )
109108
cb = qobject_cast<QComboBox *>( editor );
110109
else
@@ -115,7 +114,7 @@ QComboBox *QgsAttributeEditor::comboBox( QWidget *editor, QWidget *parent )
115114

116115
QListWidget *QgsAttributeEditor::listWidget( QWidget *editor, QWidget *parent )
117116
{
118-
QListWidget *lw = NULL;
117+
QListWidget *lw = 0;
119118
if ( editor )
120119
lw = qobject_cast<QListWidget *>( editor );
121120
else
@@ -127,9 +126,9 @@ QListWidget *QgsAttributeEditor::listWidget( QWidget *editor, QWidget *parent )
127126
QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
128127
{
129128
if ( !vl )
130-
return NULL;
129+
return 0;
131130

132-
QWidget *myWidget = NULL;
131+
QWidget *myWidget = 0;
133132
QgsVectorLayer::EditType editType = vl->editType( idx );
134133
const QgsField &field = vl->pendingFields()[idx];
135134
QVariant::Type myFieldType = field.type();
@@ -151,6 +150,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
151150

152151
myWidget = cb;
153152
}
153+
154154
}
155155
break;
156156

@@ -199,20 +199,33 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
199199

200200
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( data.mLayer ) );
201201
QMap< QString, QString > map;
202+
203+
int fi = -1;
202204
if ( layer )
203205
{
204206
int ki = layer->fieldNameIndex( data.mOrderByValue ? data.mValue : data.mKey );
205207
int vi = layer->fieldNameIndex( data.mOrderByValue ? data.mKey : data.mValue );
206208

209+
if ( !data.mFilterAttributeColumn.isNull() )
210+
fi = layer->fieldNameIndex( data.mFilterAttributeColumn );
211+
207212
if ( data.mAllowNull )
208213
map.insert( nullValue, tr( "(no selection)" ) );
209214

210215
if ( ki >= 0 && vi >= 0 )
211216
{
212-
layer->select( QgsAttributeList() << ki << vi, QgsRectangle(), false );
217+
QgsAttributeList attributes;
218+
attributes << ki;
219+
attributes << vi;
220+
if ( fi >= 0 )
221+
attributes << fi;
222+
layer->select( attributes, QgsRectangle(), false );
213223
QgsFeature f;
214224
while ( layer->nextFeature( f ) )
215225
{
226+
if ( fi >= 0 && f.attributeMap()[ fi ].toString() != data.mFilterAttributeValue )
227+
continue;
228+
216229
map.insert( f.attributeMap()[ ki ].toString(), f.attributeMap()[ vi ].toString() );
217230
}
218231
}
@@ -325,7 +338,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
325338

326339
if ( editType == QgsVectorLayer::EditRange )
327340
{
328-
QSpinBox *sb = NULL;
341+
QSpinBox *sb = 0;
329342

330343
if ( editor )
331344
sb = qobject_cast<QSpinBox *>( editor );
@@ -342,7 +355,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
342355
}
343356
else
344357
{
345-
QAbstractSlider *sl = NULL;
358+
QAbstractSlider *sl = 0;
346359

347360
if ( editor )
348361
{
@@ -369,7 +382,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
369382
}
370383
else if ( myFieldType == QVariant::Double )
371384
{
372-
QDoubleSpinBox *dsb = NULL;
385+
QDoubleSpinBox *dsb = 0;
373386
if ( editor )
374387
dsb = qobject_cast<QDoubleSpinBox*>( editor );
375388
else
@@ -392,7 +405,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
392405

393406
case QgsVectorLayer::CheckBox:
394407
{
395-
QCheckBox *cb = NULL;
408+
QCheckBox *cb = 0;
396409
if ( editor )
397410
cb = qobject_cast<QCheckBox*>( editor );
398411
else
@@ -413,9 +426,9 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
413426
case QgsVectorLayer::UniqueValuesEditable:
414427
case QgsVectorLayer::Immutable:
415428
{
416-
QLineEdit *le = NULL;
417-
QTextEdit *te = NULL;
418-
QPlainTextEdit *pte = NULL;
429+
QLineEdit *le = 0;
430+
QTextEdit *te = 0;
431+
QPlainTextEdit *pte = 0;
419432

420433
if ( editor )
421434
{
@@ -477,13 +490,13 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
477490
break;
478491

479492
case QgsVectorLayer::Hidden:
480-
myWidget = NULL;
493+
myWidget = 0;
481494
break;
482495

483496
case QgsVectorLayer::FileName:
484497
case QgsVectorLayer::Calendar:
485498
{
486-
QPushButton *pb = NULL;
499+
QPushButton *pb = 0;
487500
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
488501
if ( le )
489502
{
@@ -749,7 +762,7 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
749762
{
750763
QVariant v = value;
751764
QComboBox *cb = qobject_cast<QComboBox *>( editor );
752-
if ( cb == NULL )
765+
if ( !cb )
753766
return false;
754767

755768
if ( v.isNull() )
@@ -774,14 +787,14 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
774787
if ( editType == QgsVectorLayer::EditRange )
775788
{
776789
QSpinBox *sb = qobject_cast<QSpinBox *>( editor );
777-
if ( sb == NULL )
790+
if ( !sb )
778791
return false;
779792
sb->setValue( value.toInt() );
780793
}
781794
else
782795
{
783796
QAbstractSlider *sl = qobject_cast<QAbstractSlider *>( editor );
784-
if ( sl == NULL )
797+
if ( !sl )
785798
return false;
786799
sl->setValue( value.toInt() );
787800
}
@@ -790,7 +803,7 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
790803
else if ( myFieldType == QVariant::Double )
791804
{
792805
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( editor );
793-
if ( dsb == NULL )
806+
if ( !dsb )
794807
return false;
795808
dsb->setValue( value.toDouble() );
796809
}

‎src/ui/qgsattributetypeedit.ui

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
</sizepolicy>
9898
</property>
9999
<property name="currentIndex">
100-
<number>0</number>
100+
<number>1</number>
101101
</property>
102102
<widget class="QWidget" name="lineEditPage">
103103
<layout class="QVBoxLayout" name="verticalLayout_1">
@@ -613,7 +613,7 @@
613613
</property>
614614
</widget>
615615
</item>
616-
<item row="1" column="1">
616+
<item row="1" column="2">
617617
<widget class="QComboBox" name="valueRelationLayer"/>
618618
</item>
619619
<item row="2" column="0">
@@ -626,30 +626,10 @@
626626
</property>
627627
</widget>
628628
</item>
629-
<item row="2" column="1">
629+
<item row="2" column="2">
630630
<widget class="QComboBox" name="valueRelationKeyColumn"/>
631631
</item>
632-
<item row="3" column="0">
633-
<widget class="QLabel" name="label_7">
634-
<property name="text">
635-
<string>Value column</string>
636-
</property>
637-
<property name="buddy">
638-
<cstring>valueRelationValueColumn</cstring>
639-
</property>
640-
</widget>
641-
</item>
642-
<item row="3" column="1">
643-
<widget class="QComboBox" name="valueRelationValueColumn"/>
644-
</item>
645-
<item row="0" column="0" colspan="2">
646-
<widget class="QLabel" name="label_8">
647-
<property name="text">
648-
<string>Select layer, key column and value column</string>
649-
</property>
650-
</widget>
651-
</item>
652-
<item row="8" column="0" colspan="2">
632+
<item row="10" column="0" colspan="3">
653633
<spacer name="verticalSpacer_10">
654634
<property name="orientation">
655635
<enum>Qt::Vertical</enum>
@@ -662,7 +642,17 @@
662642
</property>
663643
</spacer>
664644
</item>
665-
<item row="4" column="1">
645+
<item row="3" column="2">
646+
<widget class="QComboBox" name="valueRelationValueColumn"/>
647+
</item>
648+
<item row="0" column="0" colspan="3">
649+
<widget class="QLabel" name="label_8">
650+
<property name="text">
651+
<string>Select layer, key column and value column</string>
652+
</property>
653+
</widget>
654+
</item>
655+
<item row="6" column="2">
666656
<widget class="QCheckBox" name="valueRelationAllowNull">
667657
<property name="layoutDirection">
668658
<enum>Qt::RightToLeft</enum>
@@ -672,7 +662,7 @@
672662
</property>
673663
</widget>
674664
</item>
675-
<item row="5" column="1">
665+
<item row="7" column="2">
676666
<widget class="QCheckBox" name="valueRelationOrderByValue">
677667
<property name="layoutDirection">
678668
<enum>Qt::RightToLeft</enum>
@@ -682,7 +672,7 @@
682672
</property>
683673
</widget>
684674
</item>
685-
<item row="6" column="1">
675+
<item row="8" column="2">
686676
<widget class="QCheckBox" name="valueRelationAllowMulti">
687677
<property name="layoutDirection">
688678
<enum>Qt::RightToLeft</enum>
@@ -692,6 +682,42 @@
692682
</property>
693683
</widget>
694684
</item>
685+
<item row="4" column="2">
686+
<widget class="QComboBox" name="valueRelationFilterColumn"/>
687+
</item>
688+
<item row="3" column="0">
689+
<widget class="QLabel" name="label_7">
690+
<property name="text">
691+
<string>Value column</string>
692+
</property>
693+
<property name="buddy">
694+
<cstring>valueRelationValueColumn</cstring>
695+
</property>
696+
</widget>
697+
</item>
698+
<item row="4" column="0">
699+
<widget class="QLabel" name="label_19">
700+
<property name="text">
701+
<string>Filter column</string>
702+
</property>
703+
<property name="buddy">
704+
<cstring>valueRelationValueColumn</cstring>
705+
</property>
706+
</widget>
707+
</item>
708+
<item row="5" column="0">
709+
<widget class="QLabel" name="label_20">
710+
<property name="text">
711+
<string>Filter value</string>
712+
</property>
713+
<property name="buddy">
714+
<cstring>valueRelationValueColumn</cstring>
715+
</property>
716+
</widget>
717+
</item>
718+
<item row="5" column="2">
719+
<widget class="QComboBox" name="valueRelationFilterValue"/>
720+
</item>
695721
</layout>
696722
</widget>
697723
<widget class="QWidget" name="uuidGenPage">

0 commit comments

Comments
 (0)
Please sign in to comment.