QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgslistwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslistwidget.h
3 --------------------------------------
4 Date : 08.2016
5 Copyright : (C) 2016 Patrick Valsecchi
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 QGSLISTWIDGET_H
17#define QGSLISTWIDGET_H
18
19#include "qgstablewidgetbase.h"
20#include <QAbstractTableModel>
21#include <QVariant>
22#include "qgis_gui.h"
23
24
25#ifndef SIP_RUN
27
34class GUI_EXPORT QgsListModel : public QAbstractTableModel
35{
36 Q_OBJECT
37 public:
38
39 explicit QgsListModel( QVariant::Type subType, QObject *parent = nullptr );
40 void setList( const QVariantList &list );
41 QVariantList list() const;
42 bool valid() const;
43
44 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
45 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
46 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
47 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
48 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
49 Qt::ItemFlags flags( const QModelIndex &index ) const override;
50 bool insertRows( int position, int rows, const QModelIndex &parent = QModelIndex() ) override;
51 bool removeRows( int position, int rows, const QModelIndex &parent = QModelIndex() ) override;
52
53 private:
54 QVariantList mLines;
55 QVariant::Type mSubType;
56};
58#endif
59
60
66class GUI_EXPORT QgsListWidget: public QgsTableWidgetBase
67{
68 Q_OBJECT
69 Q_PROPERTY( QVariantList list READ list WRITE setList )
70 public:
71
75 explicit QgsListWidget( QVariant::Type subType, QWidget *parent = nullptr );
76
80 void setList( const QVariantList &list );
81
86 QVariantList list() const { return mModel.list(); }
87
92 bool valid() const { return mModel.valid(); }
93
94 private:
95 QgsListModel mModel;
96 QVariant::Type mSubType;
97};
98
99
100#endif // QGSKEYVALUEWIDGET_H
Widget allowing to edit a QVariantList, using a table.
Definition: qgslistwidget.h:67
QVariantList list() const
Gets the edit value.
Definition: qgslistwidget.h:86
bool valid() const
Check the content is valid.
Definition: qgslistwidget.h:92
Base widget allowing to edit a collection, using a table.