Kstars

catalogobjectlistmodel.cpp
1/*
2 SPDX-FileCopyrightText: 2021 Valentin Boettcher <hiro at protagon.space; @hiro98:tchncs.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "catalogobjectlistmodel.h"
8
9CatalogObjectListModel::CatalogObjectListModel(QObject *parent,
10 std::vector<CatalogObject> objects)
11 : QAbstractTableModel{ parent }, m_objects{ std::move(objects) } {};
12
13QVariant CatalogObjectListModel::data(const QModelIndex &index, int role) const
14{
15 if (role != Qt::DisplayRole)
16 return QVariant();
17
18 const auto &obj = m_objects.at(index.row());
19
20 switch (index.column())
21 {
22 case 0:
23 return obj.typeName();
24 case 1:
25 return obj.ra().toHMSString();
26 case 2:
27 return obj.dec().toDMSString();
28 case 3:
29 return obj.mag();
30 case 4:
31 return obj.name();
32 case 5:
33 return obj.longname();
34 case 6:
35 return obj.catalogIdentifier();
36 case 7:
37 return obj.a();
38 case 8:
39 return obj.b();
40 case 9:
41 return obj.pa();
42 case 10:
43 return obj.flux();
44 default:
45 return "";
46 }
47};
48
49void CatalogObjectListModel::setObjects(std::vector<CatalogObject> objects)
50{
52 m_objects = std::move(objects);
53 emit endResetModel();
54}
55
56QVariant CatalogObjectListModel::headerData(int section, Qt::Orientation orientation,
57 int role) const
58{
59 if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
60 return QVariant();
61
62 switch (section)
63 {
64 case 0:
65 return i18n("Type");
66 case 1:
67 return i18n("RA");
68 case 2:
69 return i18n("Dec");
70 case 3:
71 return i18n("Mag");
72 case 4:
73 return i18n("Name");
74 case 5:
75 return i18n("Long Name");
76 case 6:
77 return i18n("Identifier");
78 case 7:
79 return i18n("Major Axis");
80 case 8:
81 return i18n("Minor Axis");
82 case 9:
83 return i18n("Position Angle");
84 case 10:
85 return i18n("Flux");
86 default:
87 return "";
88 }
89};
QString i18n(const char *text, const TYPE &arg...)
KIOCORE_EXPORT CopyJob * move(const QList< QUrl > &src, const QUrl &dest, JobFlags flags=DefaultFlags)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
int column() const const
int row() const const
DisplayRole
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Nov 6 2024 12:13:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.