Kstars

skyobjectlistmodel.h
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QAbstractListModel>
10#include <QDebug>
11
12class SkyObject;
13
14/**
15 * @class SkyObjectListModel
16 * A model used in Find Object Dialog in QML. Each entry is a QString (name of object) and pointer to
17 * SkyObject itself
18 *
19 * @short Model that is used in Find Object Dialog
20 * @author Artem Fedoskin, Jason Harris
21 * @version 1.0
22 */
24{
26 public:
27 enum DemoRoles
28 {
29 SkyObjectRole = Qt::UserRole + 1,
30 };
31
32 explicit SkyObjectListModel(QObject *parent = nullptr);
33
34 int rowCount(const QModelIndex &) const override { return skyObjects.size(); }
35 QVariant data(const QModelIndex &index, int role) const override;
36
37 QHash<int, QByteArray> roleNames() const override;
38
39 /**
40 * @return index of object from skyObjects with name objectName. -1 if object with such
41 * name was not found
42 */
43 int indexOf(const QString &objectName) const;
44
45 /**
46 * @short Filter the model
47 * @param regEx Regex
48 * @return Filtered string list
49 */
51
52 void setSkyObjectsList(QVector<QPair<QString, const SkyObject *>> sObjects);
53
54 public slots:
55 void removeSkyObject(SkyObject *object);
56
57 private:
59};
A model used in Find Object Dialog in QML.
int indexOf(const QString &objectName) const
QStringList filter(const QRegExp &regEx)
Filter the model.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_OBJECTQ_OBJECT
QObject * parent() const const
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:02 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.