ViewSolutions
Loading...
Searching...
No Matches
listviewmodel.h
Go to the documentation of this file.
1//#
2//# Copyright (C) 2020-2025 QuasarApp.
3//# Distributed under the GPLv3 software license, see the accompanying
4//# Everyone is permitted to copy and distribute verbatim copies
5//# of this license document, but changing it is not allowed.
6//#
7
8#ifndef LISTVIEWMODEL_H
9#define LISTVIEWMODEL_H
10#include <QAbstractItemModel>
12
13namespace ViewSolutions {
14
16 ModelData = Qt::UserRole
17};
18
19class VIEWSOLUTION_EXPORT ListViewModel: public QAbstractListModel
20{
21 Q_OBJECT
22public:
23 ListViewModel(QObject *ptr = nullptr);
25
26 int rowCount(const QModelIndex &parent = QModelIndex()) const;
27 QVariant data(const QModelIndex &index, int role) const;
28 QHash<int, QByteArray> roleNames() const;
29
30 void setExternalSource(const QList<QObject*>* newData);
31 void setSource(const QList<QObject*>& newData);
32 void addSource(QObject *data);
33
34 void clear(bool fast = false);
35
36 bool external() const;
37
38private:
39 void setExternal(bool external);
40
41 bool _external = false;
42 QList<QObject*> _data;
43 const QList<QObject*> *_externalData = nullptr;
44
45};
46
47}
48#endif // LISTVIEWMODEL_H
the ViewSolutions namespace
#define VIEWSOLUTION_EXPORT