Kstars

skyobjectlistmodel.h
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QAbstractListModel>
10 #include <QDebug>
11 
12 class 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 {
25  Q_OBJECT
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  */
50  QStringList filter(const QRegExp &regEx);
51 
52  void setSkyObjectsList(QVector<QPair<QString, const SkyObject *>> sObjects);
53 
54  public slots:
55  void removeSkyObject(SkyObject *object);
56 
57  private:
59 };
Q_OBJECTQ_OBJECT
UserRole
int indexOf(const QString &objectName) const
QStringList filter(const QRegExp &regEx)
Filter the model.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
int size() const const
Model that is used in Find Object Dialog.
Information about an object in the sky.
Definition: skyobject.h:41
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.