QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
18#include "qgsrangeconfigdlg.h"
20#include "qgsvectorlayer.h"
21
22#include <QDial>
23
28
29QgsEditorWidgetWrapper *QgsRangeWidgetFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
30{
31 return new QgsRangeWidgetWrapper( vl, fieldIdx, editor, parent );
32}
33
35{
36 return new QgsRangeConfigDlg( vl, fieldIdx, parent );
37}
38
39unsigned int QgsRangeWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
40{
41 const QgsField field = vl->fields().at( fieldIdx );
42 if ( field.type() == QMetaType::Type::Int )
43 return 20;
44 if ( field.type() == QMetaType::Type::Double )
45 return 5; // low priority because the fixed number of decimal places may alter the original data
46 if ( field.isNumeric() )
47 return 5; // widgets used support only signed 32bits (int) and double
48 return 0;
49}
50
52{
53 QHash<const char *, int> map = QHash<const char *, int>();
54 map.insert( QSlider::staticMetaObject.className(), 10 );
55 map.insert( QDial::staticMetaObject.className(), 10 );
56 map.insert( QSpinBox::staticMetaObject.className(), 10 );
57 map.insert( QDoubleSpinBox::staticMetaObject.className(), 10 );
58 return map;
59}
Base class for widgets which configure editor widget types.
QgsEditorWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor.
QIcon icon() const
Returns the icon of this widget type.
QString name() const
Returns the human readable identifier name of this widget type.
Manages an editor widget.
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:54
QMetaType::Type type
Definition qgsfield.h:61
bool isNumeric
Definition qgsfield.h:57
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Configuration widget for range widgets.
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.
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
QgsRangeWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor for QgsRangeWidgetFactory, where name is a human-readable name for the factory and icon p...
Wraps a range widget.
Represents a vector layer which manages a vector based dataset.