QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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
6 Email : denis.rouzaud@gmail.com
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
20#include "qgsdatetimeedit.h"
21
22#include <QSettings>
23
28
29QgsEditorWidgetWrapper *QgsDateTimeEditFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
30{
31 return new QgsDateTimeEditWrapper( vl, fieldIdx, editor, parent );
32}
33
35{
36 return new QgsDateTimeSearchWidgetWrapper( vl, fieldIdx, parent );
37}
38
40{
41 return new QgsDateTimeEditConfig( vl, fieldIdx, parent );
42}
43
45{
46 QHash<const char *, int> map = QHash<const char *, int>();
47 map.insert( QDateTimeEdit::staticMetaObject.className(), 10 );
48 map.insert( QgsDateTimeEdit::staticMetaObject.className(), 10 );
49 return map;
50}
51
52unsigned int QgsDateTimeEditFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
53{
54 const QgsField field = vl->fields().field( fieldIdx );
55 const QVariantMap config = field.editorWidgetSetup().config();
56 if ( field.isDateOrTime() || config.contains( QStringLiteral( "field_format" ) ) )
57 {
58 return 20;
59 }
60 else
61 {
62 return 5;
63 }
64}
QgsSearchWidgetWrapper * createSearchWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
By default a simple QgsFilterLineEdit is returned as search widget.
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.
QgsDateTimeEditFactory(const QString &name)
Constructor for QgsDateTimeEditFactory, 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 date time widget.
Wraps a date/time edit widget for searching.
This class should be subclassed for every configurable editor widget type.
Every attribute editor widget needs a factory, which inherits this class.
QVariantMap config() const
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
bool isDateOrTime
Definition qgsfield.h:57
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
Definition qgsfield.cpp:740
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 data sets.