QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
qgssingleitemmodel.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssingleitemmodel.h
3 ---------------
4 begin : May 2022
5 copyright : (C) 2022 by 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
16#ifndef QGSSINGLEITEMMODEL_H
17#define QGSSINGLEITEMMODEL_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include <QAbstractItemModel>
22
31class CORE_EXPORT QgsSingleItemModel: public QAbstractItemModel
32{
33 Q_OBJECT
34
35 public:
36
45 explicit QgsSingleItemModel( QObject *parent SIP_TRANSFERTHIS = nullptr, const QString &text = QString(),
46 const QMap< int, QVariant > &data = QMap< int, QVariant >(), Qt::ItemFlags flags = Qt::NoItemFlags );
47
56 explicit QgsSingleItemModel( QObject *parent SIP_TRANSFERTHIS,
57 const QList< QMap< int, QVariant > > &columnData,
58 Qt::ItemFlags flags = Qt::NoItemFlags );
59
60 QVariant data( const QModelIndex &index, int role ) const override;
61 Qt::ItemFlags flags( const QModelIndex &index ) const override;
62 QModelIndex index( int row, int column,
63 const QModelIndex &parent = QModelIndex() ) const override;
64 QModelIndex parent( const QModelIndex &index ) const override;
65 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
66 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
67
68 private:
69
70 QString mText;
71 QMap< int, QVariant > mData;
72 QList< QMap< int, QVariant > > mColumnData;
73 Qt::ItemFlags mFlags = Qt::NoItemFlags;
74};
75
76#endif //QGSSINGLEITEMMODEL_H
A QgsSingleItemModel subclass which contains a single read-only item.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53