QGIS API Documentation
2.12.0-Lyon
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
gui
editorwidgets
qgsuuidwidgetwrapper.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsuuidwidgetwrapper.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
16
#include "
qgsuuidwidgetwrapper.h
"
17
18
#include <QUuid>
19
20
QgsUuidWidgetWrapper::QgsUuidWidgetWrapper
(
QgsVectorLayer
* vl,
int
fieldIdx,
QWidget
* editor,
QWidget
* parent )
21
:
QgsEditorWidgetWrapper
( vl, fieldIdx, editor, parent )
22
, mLabel( NULL )
23
, mLineEdit( NULL )
24
{
25
}
26
27
QVariant
QgsUuidWidgetWrapper::value
()
28
{
29
QVariant
v;
30
31
if
( mLineEdit )
32
v = mLineEdit->
text
();
33
if
( mLabel )
34
v = mLabel->
text
();
35
36
return
v;
37
}
38
39
QWidget
*
QgsUuidWidgetWrapper::createWidget
(
QWidget
* parent )
40
{
41
return
new
QLineEdit
( parent );
42
}
43
44
void
QgsUuidWidgetWrapper::initWidget
(
QWidget
* editor )
45
{
46
mLineEdit = qobject_cast<
QLineEdit
*>( editor );
47
mLabel = qobject_cast<
QLabel
*>( editor );
48
if
( mLineEdit )
49
mLineEdit->
setEnabled
(
false
);
50
}
51
52
bool
QgsUuidWidgetWrapper::valid
()
53
{
54
return
mLineEdit || mLabel;
55
}
56
57
void
QgsUuidWidgetWrapper::setValue
(
const
QVariant
& value )
58
{
59
if
( value.
isNull
() )
60
{
61
if
( mLineEdit )
62
mLineEdit->
setText
(
QUuid::createUuid
().toString() );
63
if
( mLabel )
64
mLabel->
setText
(
QUuid::createUuid
().toString() );
65
66
valueChanged
();
67
}
68
else
69
{
70
if
( mLineEdit )
71
mLineEdit->
setText
( value.
toString
() );
72
if
( mLabel )
73
mLabel->
setText
( value.
toString
() );
74
}
75
}
76
77
void
QgsUuidWidgetWrapper::setEnabled
(
bool
enabled )
78
{
79
Q_UNUSED( enabled )
80
// Do nothing... it is always disabled
81
}
QWidget
QgsEditorWidgetWrapper::valueChanged
void valueChanged()
Will call the value() method to determine the emitted value.
Definition:
qgseditorwidgetwrapper.cpp:91
QLineEdit::text
text
QgsEditorWidgetWrapper
Manages an editor widget Widget and wrapper share the same parent.
Definition:
qgseditorwidgetwrapper.h:41
QgsUuidWidgetWrapper::QgsUuidWidgetWrapper
QgsUuidWidgetWrapper(QgsVectorLayer *vl, int fieldIdx, QWidget *editor=0, QWidget *parent=0)
Definition:
qgsuuidwidgetwrapper.cpp:20
QgsUuidWidgetWrapper::valid
bool valid() override
Return true if the widget has been properly initialized.
Definition:
qgsuuidwidgetwrapper.cpp:52
QWidget::setEnabled
void setEnabled(bool)
QVariant::isNull
bool isNull() const
QgsUuidWidgetWrapper::createWidget
QWidget * createWidget(QWidget *parent) override
This method should create a new widget with the provided parent.
Definition:
qgsuuidwidgetwrapper.cpp:39
QLabel::text
text
qgsuuidwidgetwrapper.h
QgsUuidWidgetWrapper::setValue
void setValue(const QVariant &value) override
Definition:
qgsuuidwidgetwrapper.cpp:57
QgsUuidWidgetWrapper::setEnabled
void setEnabled(bool enabled) override
Definition:
qgsuuidwidgetwrapper.cpp:77
QgsUuidWidgetWrapper::value
QVariant value() override
Will be used to access the widget's value.
Definition:
qgsuuidwidgetwrapper.cpp:27
QgsUuidWidgetWrapper::initWidget
void initWidget(QWidget *editor) override
This method should initialize the editor widget with runtime data.
Definition:
qgsuuidwidgetwrapper.cpp:44
QLineEdit
QLabel
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition:
qgsvectorlayer.h:628
QVariant::toString
QString toString() const
QUuid::createUuid
QUuid createUuid()
QVariant
Generated on Sat Oct 24 2015 04:11:25 for QGIS API Documentation by
1.8.9.1