QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ObjectItemModelBase.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 *
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
7 *
8 ****************************************************************************/
9
10#pragma once
11
12#include <QtCore/QAbstractItemModel>
13#include <QtCore/QLoggingCategory>
14#include <QtQmlIntegration/QtQmlIntegration>
15
16Q_DECLARE_LOGGING_CATEGORY(ObjectItemModelBaseLog)
17
18
20class ObjectItemModelBase : public QAbstractItemModel
21{
22 Q_OBJECT
23
24public:
25 explicit ObjectItemModelBase(QObject* parent = nullptr);
26 ~ObjectItemModelBase() override;
27
28 Q_PROPERTY(int count READ count NOTIFY countChanged)
29 Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged)
30
31 bool dirty() const { return _dirty; }
32
34 void beginResetModel();
35
37 void endResetModel();
38
39 virtual int count() const = 0;
40 virtual bool isEmpty() const { return (count() == 0); }
41 virtual void setDirty(bool dirty) = 0;
42 virtual void clear() = 0;
43
44signals:
45 void countChanged(int count);
46 void dirtyChanged(bool dirty);
47
48protected slots:
49 void _childDirtyChanged(bool dirty);
50
51protected:
52 QHash<int, QByteArray> roleNames() const override;
53 void _signalCountChangedIfNotNested();
54
55 bool _dirty = false;
56 uint _resetModelNestingCount = 0;
57
58 static constexpr int ObjectRole = Qt::UserRole;
59 static constexpr int TextRole = Qt::UserRole + 1;
60};
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
virtual void setDirty(bool dirty)=0
virtual int count() const =0
virtual void clear()=0
void dirtyChanged(bool dirty)
void countChanged(int count)
virtual bool isEmpty() const