QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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() == QMetaType::Type::Int )
41 return 20;
42 if ( field.type() == QMetaType::Type::Double )
43 return 5; // low priority because the fixed number of decimal places may alter the original data
44 if ( field.isNumeric() )
45 return 5; // widgets used support only signed 32bits (int) and double
46 return 0;
47}
48
50{
51 QHash<const char *, int> map = QHash<const char *, int>();
52 map.insert( QSlider::staticMetaObject.className(), 10 );
53 map.insert( QDial::staticMetaObject.className(), 10 );
54 map.insert( QSpinBox::staticMetaObject.className(), 10 );
55 map.insert( QDoubleSpinBox::staticMetaObject.className(), 10 );
56 return map;
57}
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:53
QMetaType::Type type
Definition qgsfield.h:60
bool isNumeric
Definition qgsfield.h:56
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
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.