Warning, file /education/kstars/kstars/dialogs/catalogobjectlistmodel.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2021 Valentin Boettcher <hiro at protagon.space; @hiro98:tchncs.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "catalogobjectlistmodel.h"
0008 
0009 CatalogObjectListModel::CatalogObjectListModel(QObject *parent,
0010                                                std::vector<CatalogObject> objects)
0011     : QAbstractTableModel{ parent }, m_objects{ std::move(objects) } {};
0012 
0013 QVariant CatalogObjectListModel::data(const QModelIndex &index, int role) const
0014 {
0015     if (role != Qt::DisplayRole)
0016         return QVariant();
0017 
0018     const auto &obj = m_objects.at(index.row());
0019 
0020     switch (index.column())
0021     {
0022         case 0:
0023             return obj.typeName();
0024         case 1:
0025             return obj.ra().toHMSString();
0026         case 2:
0027             return obj.dec().toDMSString();
0028         case 3:
0029             return obj.mag();
0030         case 4:
0031             return obj.name();
0032         case 5:
0033             return obj.longname();
0034         case 6:
0035             return obj.catalogIdentifier();
0036         case 7:
0037             return obj.a();
0038         case 8:
0039             return obj.b();
0040         case 9:
0041             return obj.pa();
0042         case 10:
0043             return obj.flux();
0044         default:
0045             return "";
0046     }
0047 };
0048 
0049 void CatalogObjectListModel::setObjects(std::vector<CatalogObject> objects)
0050 {
0051     beginResetModel();
0052     m_objects = std::move(objects);
0053     emit endResetModel();
0054 }
0055 
0056 QVariant CatalogObjectListModel::headerData(int section, Qt::Orientation orientation,
0057                                             int role) const
0058 {
0059     if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
0060         return QVariant();
0061 
0062     switch (section)
0063     {
0064         case 0:
0065             return i18n("Type");
0066         case 1:
0067             return i18n("RA");
0068         case 2:
0069             return i18n("Dec");
0070         case 3:
0071             return i18n("Mag");
0072         case 4:
0073             return i18n("Name");
0074         case 5:
0075             return i18n("Long Name");
0076         case 6:
0077             return i18n("Identifier");
0078         case 7:
0079             return i18n("Major Axis");
0080         case 8:
0081             return i18n("Minor Axis");
0082         case 9:
0083             return i18n("Position Angle");
0084         case 10:
0085             return i18n("Flux");
0086         default:
0087             return "";
0088     }
0089 };