Kstars

eclipsetool.h
1 /*
2  SPDX-FileCopyrightText: 2018 Valentin Boettcher <[email protected]>
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 
13 namespace Ui
14 {
15 class EclipseTool;
16 }
17 
18 class KSPlanetBase;
19 class QComboBox;
20 class GeoLocation;
21 
22 /**
23  * @brief The EclipseModel class
24  * @short A simple model to contain EclipseEvents.
25  */
27 {
28  Q_OBJECT
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  {
35  Q_UNUSED(parent);
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  */
89 class EclipseTool : public QFrame
90 {
91  Q_OBJECT
92 
93  public:
94  explicit EclipseTool(QWidget *parent = nullptr);
95  ~EclipseTool();
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 };
Q_OBJECTQ_OBJECT
DisplayRole
virtual bool event(QEvent *e) override
void exportAsCsv()
exportAsCsv
void clear()
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
const T & at(int i) const const
Orientation
The EclipseModel class.
Definition: eclipsetool.h:26
EclipseEvent_s getEvent(int index)
getEvent
Definition: eclipsetool.h:66
void slotAddEclipse(EclipseEvent_s eclipse)
slotAddEclipse
void reset()
reset
The EclipseTool class.
Definition: eclipsetool.h:89
QObject * parent() const const
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
Relevant data about an observing location on Earth.
Definition: geolocation.h:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.