QGIS API Documentation
2.10.1-Pisa
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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 dot kuhn at gmx 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
void
QgsUuidWidgetWrapper::setValue
(
const
QVariant
& value )
53
{
54
if
( value.
isNull
() )
55
{
56
if
( mLineEdit )
57
mLineEdit->
setText
(
QUuid::createUuid
().toString() );
58
if
( mLabel )
59
mLabel->
setText
(
QUuid::createUuid
().toString() );
60
61
valueChanged
();
62
}
63
else
64
{
65
if
( mLineEdit )
66
mLineEdit->
setText
( value.
toString
() );
67
if
( mLabel )
68
mLabel->
setText
( value.
toString
() );
69
}
70
}
71
72
void
QgsUuidWidgetWrapper::setEnabled
(
bool
enabled )
73
{
74
Q_UNUSED( enabled )
75
// Do nothing... it is always disabled
76
}
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
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:52
QgsUuidWidgetWrapper::setEnabled
void setEnabled(bool enabled) override
Definition:
qgsuuidwidgetwrapper.cpp:72
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:620
QVariant::toString
QString toString() const
QUuid::createUuid
QUuid createUuid()
QVariant
Generated on Sat Aug 22 2015 02:53:41 for QGIS API Documentation by
1.8.6