QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ObjectListModelBase.cc
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#include "ObjectListModelBase.h"
11#include "QGCLoggingCategory.h"
12
13QGC_LOGGING_CATEGORY(ObjectListModelBaseLog, "API.ObjectListModelBase")
14
16 : ObjectItemModelBase(parent)
17{
18}
19
23
24// Flat-list overrides — same semantics as QAbstractListModel
25
26QModelIndex ObjectListModelBase::index(int row, int column, const QModelIndex& parent) const
27{
28 if (parent.isValid() || column != 0 || row < 0 || row >= rowCount()) {
29 return {};
30 }
31 return createIndex(row, 0);
32}
33
34QModelIndex ObjectListModelBase::parent(const QModelIndex& child) const
35{
37 return {};
38}
39
40int ObjectListModelBase::columnCount(const QModelIndex& parent) const
41{
43 return 1;
44}
45
46bool ObjectListModelBase::hasChildren(const QModelIndex& parent) const
47{
48 // Only the root (invalid parent) has children in a flat list
49 return !parent.isValid() && rowCount() > 0;
50}
#define QGC_LOGGING_CATEGORY(name, categoryStr)
int rowCount(const QModelIndex &parent=QModelIndex()) const override=0
QModelIndex index(int row, int column=0, const QModelIndex &parent=QModelIndex()) const override
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
QModelIndex parent(const QModelIndex &child) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override