QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsdatetimeeditfactory.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsdatetimeeditfactory.cpp
3 --------------------------------------
4 Date : 03.2014
5 Copyright : (C) 2014 Denis Rouzaud
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 "qgsdatetimeedit.h"
22
23#include <QSettings>
24
29
30QgsEditorWidgetWrapper *QgsDateTimeEditFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
31{
32 return new QgsDateTimeEditWrapper( vl, fieldIdx, editor, parent );
33}
34
36{
37 return new QgsDateTimeSearchWidgetWrapper( vl, fieldIdx, parent );
38}
39
41{
42 return new QgsDateTimeEditConfig( vl, fieldIdx, parent );
43}
44
46{
47 QHash<const char *, int> map = QHash<const char *, int>();
48 map.insert( QDateTimeEdit::staticMetaObject.className(), 10 );
49 map.insert( QgsDateTimeEdit::staticMetaObject.className(), 10 );
50 return map;
51}
52
53unsigned int QgsDateTimeEditFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
54{
55 const QgsField field = vl->fields().field( fieldIdx );
56 const QVariantMap config = field.editorWidgetSetup().config();
57 if ( field.isDateOrTime() || config.contains( QStringLiteral( "field_format" ) ) )
58 {
59 return 20;
60 }
61 else
62 {
63 return 5;
64 }
65}
Configuration widget for datetime widgets.
QgsSearchWidgetWrapper * createSearchWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
By default a simple QgsFilterLineEdit is returned as search widget.
QgsDateTimeEditFactory(const QString &name, const QIcon &icon=QIcon())
Constructor for QgsDateTimeEditFactory, where name is a human-readable name for the factory and icon ...
QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const override
This method allows disabling this editor widget type for a certain field.
QHash< const char *, int > supportedWidgetTypes() override
Returns a list of widget types which this editor widget supports.
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
Wraps a date time widget.
Wraps a date/time edit widget for searching.
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.
QVariantMap config() const
Returns the widget configuration.
Manages an editor widget.
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:54
bool isDateOrTime
Definition qgsfield.h:58
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
Definition qgsfield.cpp:747
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
Shows a search widget on a filter form.
Represents a vector layer which manages a vector based dataset.