QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsbinarywidgetfactory.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsbinarywidgetfactory.cpp
3 -------------------------
4 Date : November 2018
5 Copyright : (C) 2018 Nyall Dawson
6 Email : nyall dot dawson at gmail dot 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
17
19#include "qgsdummyconfigdlg.h"
21#include "qgsvectorlayer.h"
22
23QgsBinaryWidgetFactory::QgsBinaryWidgetFactory( const QString &name, QgsMessageBar *messageBar, const QIcon &icon )
25 , mMessageBar( messageBar )
26{
27}
28
29QgsEditorWidgetWrapper *QgsBinaryWidgetFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
30{
31 return new QgsBinaryWidgetWrapper( vl, fieldIdx, editor, parent, mMessageBar );
32}
33
35{
36 return new QgsDummyConfigDlg( vl, fieldIdx, parent, QObject::tr( "A widget for interacting with binary (BLOB) fields." ) );
37}
38
39unsigned int QgsBinaryWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
40{
41 const QgsField field = vl->fields().field( fieldIdx );
42 const QMetaType::Type type = field.type();
43 // ByteArray fields only
44 return type == QMetaType::Type::QByteArray ? 20 : 0;
45}
unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const override
This method allows disabling this editor widget type for a certain field.
QgsBinaryWidgetFactory(const QString &name, QgsMessageBar *messageBar, const QIcon &icon=QIcon())
Constructor for QgsBinaryWidgetFactory, 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.
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
Widget wrapper for binary (BLOB) fields.
Configuration widget for dummy widgets.
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
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
A bar for displaying non-blocking messages to the user.
Represents a vector layer which manages a vector based dataset.