Kstars

eclipsetool.h
1/*
2 SPDX-FileCopyrightText: 2018 Valentin Boettcher <valentin@boettcher.cf>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8#include <QFrame>
9#include <QHash>
10#include <QAbstractTableModel>
11#include "eclipsetool/lunareclipsehandler.h"
12
13namespace Ui
14{
15class EclipseTool;
16}
17
18class KSPlanetBase;
19class QComboBox;
20class GeoLocation;
21
22/**
23 * @brief The EclipseModel class
24 * @short A simple model to contain EclipseEvents.
25 */
27{
29 public:
30 // This is reimplemented boilerplate from QAbstractModel
31 explicit EclipseModel(QObject * parent = nullptr);
32 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
33 int columnCount(const QModelIndex &parent = QModelIndex()) const override
34 {
36 return COLUMNS;
37 }
38 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
39 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
40
41 public slots:
42 /**
43 * @brief reset
44 * @short resets the data and the model
45 */
46 void reset();
47
48 /**
49 * @brief slotAddEclipse
50 * @param eclipse
51 * @short add an eclipse to the model
52 */
53 void slotAddEclipse(EclipseEvent_s eclipse);
54
55 /**
56 * @brief exportAsCsv
57 * @short Export data as CSV (plus dialog)
58 */
59 void exportAsCsv();
60
61 /**
62 * @brief getEvent
63 * @param index
64 * @short retrieve an event
65 */
66 EclipseEvent_s getEvent(int index)
67 {
68 return m_eclipses.at(index);
69 }
70
71 private slots:
72 // reimplemented to clear the data
73 void resetInternalData()
74 {
75 m_eclipses.clear();
76 }
77
78 private:
80 const int COLUMNS { 5 };
81};
82
83/**
84 * @brief The EclipseTool class
85 * @short The UI for the Eclipsetool.
86 * Currently only lunar eclipses are implemented.
87 * Others will follow.
88 */
89class EclipseTool : public QFrame
90{
92
93 public:
94 explicit EclipseTool(QWidget *parent = nullptr);
96
97 private slots:
98 /**
99 * @brief slotLocation
100 * @short slot for setting the geolocation
101 */
102 void slotLocation();
103
104 /**
105 * @brief slotCompute
106 * @short slot to start the computation
107 */
108 void slotCompute();
109
110 /**
111 * @brief slotFinished
112 * @short slot to clear any residuals
113 */
114 void slotFinished();
115
116 /**
117 * @brief slotContextMenu
118 * @short show context menu for an eclipse
119 * @param pos
120 */
121 void slotContextMenu(QPoint pos);
122
123 /**
124 * @brief slotView
125 * @param event
126 * @short view an eclipse on the SkyMap
127 */
128 void slotView(EclipseEvent_s event);
129
130 private:
131 Ui::EclipseTool *ui;
132
133 QVector<std::pair<int, QString>> m_object1List;
134 QVector<std::pair<int, QString>> m_object2List;
135
136 GeoLocation * m_geoLocation { nullptr };
137 EclipseModel m_model;
138};
The EclipseModel class.
Definition eclipsetool.h:27
void reset()
reset
EclipseEvent_s getEvent(int index)
getEvent
Definition eclipsetool.h:66
void slotAddEclipse(EclipseEvent_s eclipse)
slotAddEclipse
void exportAsCsv()
exportAsCsv
The EclipseTool class.
Definition eclipsetool.h:90
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
A subclass of TrailObject that provides additional information needed for most solar system objects.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
virtual bool event(QEvent *e) override
const_reference at(qsizetype i) const const
void clear()
Q_OBJECTQ_OBJECT
QObject * parent() const const
DisplayRole
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:01:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.