Kstars

wiview.h
1 /*
2  SPDX-FileCopyrightText: 2012 Samikshan Bairagya <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QString>
10 #include <QWidget>
11 
12 #include <memory>
13 
15 class QQmlContext;
16 class QQuickItem;
17 class QQuickView;
18 
19 class ModelManager;
20 class ObsConditions;
21 class SkyObject;
22 class SkyObjItem;
23 
24 /**
25  * @class WIView
26  * @brief Manages the QML user interface for What's Interesting. WIView is used to display the
27  * QML UI using a QQuickView. It acts on all signals emitted by the UI and manages the data
28  * sent to the UI for display.
29  *
30  * @author Samikshan Bairagya
31  */
32 class WIView : public QWidget
33 {
34  Q_OBJECT
35  public:
36  /**
37  * @brief Constructor - Store QML components as QObject pointers.
38  * Connect signals from various QML components into public slots.
39  * Displays the user interface for What's Interesting
40  */
41  explicit WIView(QWidget *parent = nullptr);
42 
43  virtual ~WIView() override = default;
44 
45  /** Load details-view for selected sky-object */
46  void loadDetailsView(SkyObjItem *soitem, int index);
47 
48  /** Updates sky-object list models */
49  void updateModel(ObsConditions& obs);
50 
51  inline QQuickView *getWIBaseView() const { return m_BaseView; }
52 
53  public slots:
54 
55  /**
56  * @brief public slot - Act upon signal emitted when category of sky-object is selected
57  * from category selection view of the QML UI.
58  * @param model Category selected
59  */
60  void onCategorySelected(QString model);
61 
62  /**
63  * @brief public slot - Act upon signal emitted when an item is selected from list of sky-objects.
64  * Display details-view for the skyobject selected.
65  * @param index Index of item in the list of skyobjects.
66  */
67  void onSoListItemClicked(int index);
68 
69  /** public slot - Show details-view for next sky-object from list of current sky-objects's category. */
70  void onNextObjClicked();
71 
72  /**
73  * @brief public slot - Show details-view for previous sky-object from list of current sky-objects's
74  * category.
75  */
76  void onPrevObjClicked();
77 
78  /** public slot - Slew map to current sky-object in the details view. */
79  void onCenterButtonClicked();
80 
81  /** public slot - Slew map to current sky-object in the details view. */
83 
84  /** public slot - Open Details Dialog to show more details for current sky-object. */
86 
87  /** public slot - Open WI settings dialog. */
88  void onSettingsIconClicked();
89 
90  void onInspectIconClicked(bool checked) { inspectOnClick = checked; }
91 
92  /** public slot - Reload list of visible sky-objects. */
93  void onReloadIconClicked();
94 
95  void onVisibleIconClicked(bool checked);
96 
97  void onFavoriteIconClicked(bool checked);
98 
99  void onUpdateIconClicked();
100 
101  void updateWikipediaDescription(SkyObjItem *soitem);
102  void loadObjectDescription(SkyObjItem *soitem);
103  void tryToUpdateWikipediaInfo(SkyObjItem *soitem, QString name);
104  void loadObjectInfoBox(SkyObjItem *soitem);
105  void saveImageURL(SkyObjItem *soitem, QString imageURL);
106  void saveInfoURL(SkyObjItem *soitem, QString infoURL);
107  void saveObjectInfoBoxText(SkyObjItem *soitem, QString type, QString infoText);
108  void downloadWikipediaImage(SkyObjItem *soitem, QString imageURL);
109  void inspectSkyObject(const QString& name);
110  void inspectSkyObjectOnClick(SkyObject *obj);
111  void inspectSkyObject(SkyObject *obj);
112  bool inspectOnClickIsActive() { return inspectOnClick; }
114  void tryToUpdateWikipediaInfoInModel(bool onlyMissing);
115  void refreshListView();
116  void updateProgress(double value);
117  void setProgressBarVisible(bool visible);
118  void setNightVisionOn(bool on);
119 
120  private:
121  QString getWikipediaName(SkyObjItem *soitem);
122 
123  QQuickItem *m_BaseObj { nullptr };
124  QQuickItem *m_ViewsRowObj { nullptr };
125  QQuickItem *m_CategoryTitle { nullptr };
126  QQuickItem *m_SoListObj { nullptr };
127  QQuickItem *m_DetailsViewObj { nullptr };
128  QQuickItem *m_ProgressBar { nullptr };
129  QQuickItem *m_loadingMessage { nullptr };
130  QQuickItem *m_NextObj { nullptr };
131  QQuickItem *m_PrevObj { nullptr };
132  QQuickItem *m_CenterButtonObj { nullptr };
133  QQuickItem *m_SlewTelescopeButtonObj { nullptr };
134  QQuickItem *m_DetailsButtonObj { nullptr };
135  QQuickItem *inspectIconObj { nullptr };
136  QQuickItem *visibleIconObj { nullptr };
137  QQuickItem *favoriteIconObj { nullptr };
138  QQmlContext *m_Ctxt { nullptr };
139  QObject *infoBoxText { nullptr };
140  QObject *descTextObj { nullptr };
141  QObject *nightVision { nullptr };
142  QObject *autoTrackCheckbox { nullptr };
143  QObject *autoCenterCheckbox { nullptr };
144 
145  QQuickView *m_BaseView { nullptr };
146  ObsConditions *m_Obs { nullptr };
147  std::unique_ptr<ModelManager> m_ModManager;
148  /// Current sky object item.
149  SkyObjItem *m_CurSoItem { nullptr };
150  /// Created sky object item on-demand
151  std::unique_ptr<SkyObjItem> trackedItem;
152  /// Index of current sky-object item in Details view.
153  int m_CurIndex { 0 };
154  /// Currently selected category from WI QML view
155  QString m_CurrentObjectListName;
156  std::unique_ptr<QNetworkAccessManager> manager;
157  bool inspectOnClick { false };
158 };
Q_OBJECTQ_OBJECT
void onPrevObjClicked()
public slot - Show details-view for previous sky-object from list of current sky-objects's category.
Definition: wiview.cpp:299
void onNextObjClicked()
public slot - Show details-view for next sky-object from list of current sky-objects's category.
Definition: wiview.cpp:285
Manages the QML user interface for What's Interesting. WIView is used to display the QML UI using a Q...
Definition: wiview.h:32
void onCenterButtonClicked()
public slot - Slew map to current sky-object in the details view.
Definition: wiview.cpp:313
void onDetailsButtonClicked()
public slot - Open Details Dialog to show more details for current sky-object.
Definition: wiview.cpp:370
void updateObservingConditions()
Definition: wiview.cpp:215
Manages models for QML listviews of different types of sky-objects.
Definition: modelmanager.h:27
void loadDetailsView(SkyObjItem *soitem, int index)
Load details-view for selected sky-object.
Definition: wiview.cpp:501
WIView(QWidget *parent=nullptr)
Constructor - Store QML components as QObject pointers.
Definition: wiview.cpp:40
void onSlewTelescopeButtonClicked()
public slot - Slew map to current sky-object in the details view.
Definition: wiview.cpp:328
void onCategorySelected(QString model)
public slot - Act upon signal emitted when category of sky-object is selected from category selection...
Definition: wiview.cpp:254
void onReloadIconClicked()
public slot - Reload list of visible sky-objects.
Definition: wiview.cpp:389
void onSettingsIconClicked()
public slot - Open WI settings dialog.
Definition: wiview.cpp:383
void updateModel(ObsConditions &obs)
Updates sky-object list models.
Definition: wiview.cpp:460
Information about an object in the sky.
Definition: skyobject.h:41
QObject * parent() const const
void onSoListItemClicked(int index)
public slot - Act upon signal emitted when an item is selected from list of sky-objects.
Definition: wiview.cpp:278
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Aug 13 2022 04:02:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.