QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsrangewidgetfactory.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsrangewidgetfactory.cpp
3 --------------------------------------
4 Date : 5.1.2014
5 Copyright : (C) 2014 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
17#include "qgsrangeconfigdlg.h"
19#include "qgsvectorlayer.h"
20#include <QDial>
21
24{
25}
26
27QgsEditorWidgetWrapper *QgsRangeWidgetFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
28{
29 return new QgsRangeWidgetWrapper( vl, fieldIdx, editor, parent );
30}
31
33{
34 return new QgsRangeConfigDlg( vl, fieldIdx, parent );
35}
36
37unsigned int QgsRangeWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
38{
39 const QgsField field = vl->fields().at( fieldIdx );
40 if ( field.type() == QVariant::Int ) return 20;
41 if ( field.type() == QVariant::Double ) return 5; // low priority because the fixed number of decimal places may alter the original data
42 if ( field.isNumeric() ) return 5; // widgets used support only signed 32bits (int) and double
43 return 0;
44}
45
47{
48 QHash<const char *, int> map = QHash<const char *, int>();
49 map.insert( QSlider::staticMetaObject.className(), 10 );
50 map.insert( QDial::staticMetaObject.className(), 10 );
51 map.insert( QSpinBox::staticMetaObject.className(), 10 );
52 map.insert( QDoubleSpinBox::staticMetaObject.className(), 10 );
53 return map;
54}
This class should be subclassed for every configurable editor widget type.
Every attribute editor widget needs a factory, which inherits this class.
Manages an editor widget Widget and wrapper share the same parent.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:51
Q_GADGET bool isNumeric
Definition: qgsfield.h:54
QVariant::Type type
Definition: qgsfield.h:58
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Definition: qgsfields.cpp:163
QHash< const char *, int > supportedWidgetTypes() override
Returns a list of widget types which this editor widget supports.
QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
QgsRangeWidgetFactory(const QString &name)
Constructor for QgsRangeWidgetFactory, where name is a human-readable name for the factory.
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
Wraps a range widget.
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
const QgsField & field
Definition: qgsfield.h:463