QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsrelationreferencewidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrelationreferencewidget.h
3 --------------------------------------
4 Date : 20.4.2013
5 Copyright : (C) 2013 Matthias Kuhn
6 Email : matthias at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSRELATIONREFERENCEWIDGET_H
17#define QGSRELATIONREFERENCEWIDGET_H
18
20#include "qgis_sip.h"
21#include "qgsfeature.h"
22#include "qobjectuniqueptr.h"
23
24#include <QComboBox>
25#include <QToolButton>
26#include <QLineEdit>
27#include <QHBoxLayout>
28#include <QStandardItemModel>
29#include "qgis_gui.h"
30
33class QgsMapCanvas;
34class QgsMessageBar;
35class QgsHighlight;
36class QgsMapTool;
42class QLabel;
43
44#ifdef SIP_RUN
45% ModuleHeaderCode
46// fix to allow compilation with sip that for some reason
47// doesn't add this include to the file where the code from
48// ConvertToSubClassCode goes.
50% End
51#endif
52
57class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
58{
59
60#ifdef SIP_RUN
62 if ( qobject_cast<QgsRelationReferenceWidget *>( sipCpp ) )
63 sipType = sipType_QgsRelationReferenceWidget;
64 else
65 sipType = NULL;
67#endif
68
69 Q_OBJECT
70 Q_PROPERTY( bool openFormButtonVisible READ openFormButtonVisible WRITE setOpenFormButtonVisible )
71
72 public:
73
75 {
78 Scale
79 };
80
81 explicit QgsRelationReferenceWidget( QWidget *parent SIP_TRANSFERTHIS );
82
84
85 void setRelation( const QgsRelation &relation, bool allowNullValue );
86
87 void setRelationEditable( bool editable );
88
93 Q_DECL_DEPRECATED void setForeignKey( const QVariant &value ) SIP_DEPRECATED;
94
99 void setForeignKeys( const QVariantList &values );
100
105 Q_DECL_DEPRECATED QVariant foreignKey() const SIP_DEPRECATED;
106
108
113 QVariantList foreignKeys() const;
114
120 void setEditorContext( const QgsAttributeEditorContext &context, QgsMapCanvas *canvas, QgsMessageBar *messageBar );
121
123 bool embedForm() { return mEmbedForm; }
124 void setEmbedForm( bool display );
125
127 bool readOnlySelector() { return mReadOnlySelector; }
128 void setReadOnlySelector( bool readOnly );
129
131 bool allowMapIdentification() { return mAllowMapIdentification; }
132 void setAllowMapIdentification( bool allowMapIdentification );
133
135 void setFilterFields( const QStringList &filterFields );
136
138 bool openFormButtonVisible() { return mOpenFormButtonVisible; }
139 void setOpenFormButtonVisible( bool openFormButtonVisible );
140
146 bool chainFilters() const { return mChainFilters; }
147
154 void setChainFilters( bool chainFilters );
155
159 QString filterExpression() const { return mFilterExpression; };
160
165 void setFilterExpression( const QString &filterExpression );
166
171 QgsFeature referencedFeature() const;
172
177 void showIndeterminateState();
178
184 bool allowAddFeatures() const;
185
191 void setAllowAddFeatures( bool allowAddFeatures );
192
197 QgsRelation relation() const;
198
204 void setFormFeature( const QgsFeature &formFeature );
205
210 QString referencedLayerDataSource() const;
211
216 void setReferencedLayerDataSource( const QString &referencedLayerDataSource );
217
222 QString referencedLayerProviderKey() const;
223
228 void setReferencedLayerProviderKey( const QString &referencedLayerProviderKey );
229
234 QString referencedLayerId() const;
235
240 void setReferencedLayerId( const QString &referencedLayerId );
241
246 QString referencedLayerName() const;
247
252 void setReferencedLayerName( const QString &referencedLayerName );
253
258 int fetchLimit() const {return mFetchLimit; }
259
264 void setFetchLimit( int fetchLimit ) {mFetchLimit = fetchLimit; }
265
266
267 public slots:
269 void openForm();
270
272 void mapIdentification();
273
275 void deleteForeignKeys();
276
277 protected:
278 void showEvent( QShowEvent *e ) override;
279
280 void init();
281
282 signals:
283
288 Q_DECL_DEPRECATED void foreignKeyChanged( const QVariant & ) SIP_DEPRECATED;
289
294 void foreignKeysChanged( const QVariantList & );
295
296 private slots:
297 void highlightActionTriggered( QAction *action );
298 void deleteHighlight();
299 void comboReferenceChanged();
300 void featureIdentified( const QgsFeature &feature );
301 void setMapTool( QgsMapTool *mapTool );
302 void unsetMapTool();
303 void mapToolDeactivated();
304 void filterChanged();
305 void addEntry();
306 void updateAddEntryButton();
307 void entryAdded( const QgsFeature &f );
308 void onKeyPressed( QKeyEvent *e );
309
310 private:
311 void highlightFeature( QgsFeature f = QgsFeature(), CanvasExtent canvasExtent = Fixed );
312 void updateAttributeEditorFrame( const QgsFeature &feature );
313 void disableChainedComboBoxes( const QComboBox *cb );
314 void emitForeignKeysChanged( const QVariantList &foreignKeys, bool force = false );
315
316 // initialized
317 QgsAttributeEditorContext mEditorContext;
318 QgsMapCanvas *mCanvas = nullptr;
319 QgsMessageBar *mMessageBar = nullptr;
320 QVariantList mForeignKeys;
321 QgsFeature mFeature;
322 QgsFeature mFormFeature;
323 // Index of the referenced layer key
324 QStringList mReferencedFields;
325 bool mAllowNull = true;
326 QgsHighlight *mHighlight = nullptr;
327 QgsMapTool *mCurrentMapTool = nullptr;
330 QgsMessageBarItem *mMessageBarItem = nullptr;
331 QgsAttributeForm *mReferencedAttributeForm = nullptr;
332 QgsVectorLayer *mReferencedLayer = nullptr;
333 QgsVectorLayer *mReferencingLayer = nullptr;
334 QgsFeatureListComboBox *mComboBox = nullptr;
335 QList<QComboBox *> mFilterComboBoxes;
336 QString mFilterExpression;
337 QWidget *mWindowWidget = nullptr;
338 bool mShown = false;
339 QgsRelation mRelation;
340 bool mIsEditable = true;
341 QStringList mFilterFields;
342 QMap<QString, QMap<QString, QSet<QString> > > mFilterCache;
343 bool mInitialized = false;
344 int mFetchLimit = 0;
345
346 // Q_PROPERTY
347 bool mEmbedForm = false;
348 bool mReadOnlySelector = false;
349 bool mAllowMapIdentification = false;
350 bool mOpenFormButtonVisible = true;
351 bool mChainFilters = false;
352 bool mAllowAddFeatures = false;
353 QString mReferencedLayerId;
354 QString mReferencedLayerName;
355 QString mReferencedLayerDataSource;
356 QString mReferencedLayerProviderKey;
357
358 // UI
359 QVBoxLayout *mTopLayout = nullptr;
360 QToolButton *mMapIdentificationButton = nullptr;
361 QToolButton *mRemoveFKButton = nullptr;
362 QToolButton *mOpenFormButton = nullptr;
363 QToolButton *mHighlightFeatureButton = nullptr;
364 QToolButton *mAddEntryButton = nullptr;
365 QAction *mHighlightFeatureAction = nullptr;
366 QAction *mScaleHighlightFeatureAction = nullptr;
367 QAction *mPanHighlightFeatureAction = nullptr;
368 QWidget *mChooserContainer = nullptr;
369 QWidget *mFilterContainer = nullptr;
370 QHBoxLayout *mFilterLayout = nullptr;
371 QgsCollapsibleGroupBox *mAttributeEditorFrame = nullptr;
372 QVBoxLayout *mAttributeEditorLayout = nullptr;
373 QLabel *mInvalidLabel = nullptr;
374
375 friend class TestQgsRelationReferenceWidget;
376};
377
378#endif // QGSRELATIONREFERENCEWIDGET_H
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
This class contains context information for attribute editor widgets.
A groupbox that collapses/expands when toggled and can save its collapsed and checked states.
This offers a combobox with autocompleter that allows selecting features from a layer.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:56
A class for highlight features on the map.
Map canvas is a class for displaying all GIS data types on a canvas.
This tool digitizes geometry of new point/line/polygon features on already existing vector layers Onc...
The QgsMapToolIdentifyFeature class is a map tool to identify a feature on a chosen layer.
Abstract base class for all map tools.
Definition qgsmaptool.h:71
Represents an item shown within a QgsMessageBar widget.
A bar for displaying non-blocking messages to the user.
QString filterExpression() const
Returns the currently set filter expression.
void foreignKeysChanged(const QVariantList &)
Emitted when the foreign keys changed.
bool openFormButtonVisible()
determines the open form button is visible in the widget
Q_DECL_DEPRECATED void foreignKeyChanged(const QVariant &)
Emitted when the foreign key changed.
bool allowMapIdentification()
determines if the widget offers the possibility to select the related feature on the map (using a ded...
bool chainFilters() const
Determines if the filters are chained.
int fetchLimit() const
Returns the limit of fetched features (0 means all features)
bool readOnlySelector()
determines if the drop-down is enabled
void setFetchLimit(int fetchLimit)
Set the limit of fetched features (0 means all features)
Methods in this class are used to handle basic operations on vector layers.
Represents a vector layer which manages a vector based data sets.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:186
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_END
Definition qgis_sip.h:203