QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgskeyvaluewidget.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgskeyvaluewidget.h
3
--------------------------------------
4
Date : 08.2016
5
Copyright : (C) 2016 Patrick Valsecchi
6
Email : patrick.valsecchi@camptocamp.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
16
#ifndef QGSKEYVALUEWIDGET_H
17
#define QGSKEYVALUEWIDGET_H
18
19
#include "qgis_gui.h"
20
#include "
qgis_sip.h
"
21
#include "
qgstablewidgetbase.h
"
22
23
#include <QAbstractTableModel>
24
#include <QMap>
25
26
#ifndef SIP_RUN
28
34
class
GUI_EXPORT QgsKeyValueModel :
public
QAbstractTableModel
35
{
36
Q_OBJECT
37
public
:
38
explicit
QgsKeyValueModel( QObject *parent =
nullptr
);
39
void
setMap(
const
QVariantMap &map );
40
QVariantMap map()
const
;
41
42
int
rowCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
43
int
columnCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
44
QVariant headerData(
int
section, Qt::Orientation orientation,
int
role )
const override
;
45
QVariant data(
const
QModelIndex &index,
int
role = Qt::DisplayRole )
const override
;
46
bool
setData(
const
QModelIndex &index,
const
QVariant &value,
int
role = Qt::EditRole )
override
;
47
Qt::ItemFlags flags(
const
QModelIndex &index )
const override
;
48
bool
insertRows(
int
position,
int
rows,
const
QModelIndex &parent = QModelIndex() )
override
;
49
bool
removeRows(
int
position,
int
rows,
const
QModelIndex &parent = QModelIndex() )
override
;
50
void
setReadOnly(
bool
readOnly );
51
typedef
QPair<QString, QVariant> Line;
52
53
private
:
54
bool
mReadOnly =
false
;
55
QVector<Line> mLines;
56
};
58
#endif
59
64
class
GUI_EXPORT
QgsKeyValueWidget
:
public
QgsTableWidgetBase
65
{
66
Q_OBJECT
67
Q_PROPERTY( QVariantMap
map
READ
map
WRITE
setMap
)
68
public
:
72
explicit
QgsKeyValueWidget
( QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
);
73
77
void
setMap
(
const
QVariantMap &
map
);
78
83
QVariantMap
map
()
const
{
return
mModel.map(); }
84
85
public
slots:
86
87
void
setReadOnly(
bool
readOnly )
override
;
88
89
private
:
90
QgsKeyValueModel mModel;
91
};
92
93
94
#endif
// QGSKEYVALUEWIDGET_H
QgsKeyValueWidget::QgsKeyValueWidget
QgsKeyValueWidget(QWidget *parent=nullptr)
Constructor.
Definition
qgskeyvaluewidget.cpp:20
QgsKeyValueWidget::map
QVariantMap map
Definition
qgskeyvaluewidget.h:67
QgsKeyValueWidget::map
QVariantMap map() const
Gets the edit value.
Definition
qgskeyvaluewidget.h:83
QgsKeyValueWidget::setMap
void setMap(const QVariantMap &map)
Set the initial value of the widget.
Definition
qgskeyvaluewidget.cpp:27
QgsTableWidgetBase::QgsTableWidgetBase
QgsTableWidgetBase(QWidget *parent)
Constructor.
Definition
qgstablewidgetbase.cpp:20
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
qgstablewidgetbase.h
Generated on
for QGIS API Documentation by
1.17.0