File indexing completed on 2024-03-24 03:47:32
0001 /* 0002 SPDX-FileCopyrightText: 2012 Samikshan Bairagya <samikshan@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QString> 0010 #include <QWidget> 0011 0012 #include <memory> 0013 0014 class QNetworkAccessManager; 0015 class QQmlContext; 0016 class QQuickItem; 0017 class QQuickView; 0018 0019 class ModelManager; 0020 class ObsConditions; 0021 class SkyObject; 0022 class SkyObjItem; 0023 0024 /** 0025 * @class WIView 0026 * @brief Manages the QML user interface for What's Interesting. WIView is used to display the 0027 * QML UI using a QQuickView. It acts on all signals emitted by the UI and manages the data 0028 * sent to the UI for display. 0029 * 0030 * @author Samikshan Bairagya 0031 */ 0032 class WIView : public QWidget 0033 { 0034 Q_OBJECT 0035 public: 0036 /** 0037 * @brief Constructor - Store QML components as QObject pointers. 0038 * Connect signals from various QML components into public slots. 0039 * Displays the user interface for What's Interesting 0040 */ 0041 explicit WIView(QWidget *parent = nullptr); 0042 0043 virtual ~WIView() override = default; 0044 0045 /** Load details-view for selected sky-object */ 0046 void loadDetailsView(SkyObjItem *soitem, int index); 0047 0048 /** Updates sky-object list models */ 0049 void updateModel(ObsConditions& obs); 0050 0051 inline QQuickView *getWIBaseView() const { return m_BaseView; } 0052 0053 public slots: 0054 0055 /** 0056 * @brief public slot - Act upon signal emitted when category of sky-object is selected 0057 * from category selection view of the QML UI. 0058 * @param model Category selected 0059 */ 0060 void onCategorySelected(QString model); 0061 0062 /** 0063 * @brief public slot - Act upon signal emitted when an item is selected from list of sky-objects. 0064 * Display details-view for the skyobject selected. 0065 * @param index Index of item in the list of skyobjects. 0066 */ 0067 void onSoListItemClicked(int index); 0068 0069 /** public slot - Show details-view for next sky-object from list of current sky-objects's category. */ 0070 void onNextObjClicked(); 0071 0072 /** 0073 * @brief public slot - Show details-view for previous sky-object from list of current sky-objects's 0074 * category. 0075 */ 0076 void onPrevObjClicked(); 0077 0078 /** public slot - Slew map to current sky-object in the details view. */ 0079 void onCenterButtonClicked(); 0080 0081 /** public slot - Slew map to current sky-object in the details view. */ 0082 void onSlewTelescopeButtonClicked(); 0083 0084 /** public slot - Open Details Dialog to show more details for current sky-object. */ 0085 void onDetailsButtonClicked(); 0086 0087 /** public slot - Open WI settings dialog. */ 0088 void onSettingsIconClicked(); 0089 0090 void onInspectIconClicked(bool checked) { inspectOnClick = checked; } 0091 0092 /** public slot - Reload list of visible sky-objects. */ 0093 void onReloadIconClicked(); 0094 0095 void onVisibleIconClicked(bool checked); 0096 0097 void onFavoriteIconClicked(bool checked); 0098 0099 void onUpdateIconClicked(); 0100 0101 void updateWikipediaDescription(SkyObjItem *soitem); 0102 void loadObjectDescription(SkyObjItem *soitem); 0103 void tryToUpdateWikipediaInfo(SkyObjItem *soitem, QString name); 0104 void loadObjectInfoBox(SkyObjItem *soitem); 0105 void saveImageURL(SkyObjItem *soitem, QString imageURL); 0106 void saveInfoURL(SkyObjItem *soitem, QString infoURL); 0107 void saveObjectInfoBoxText(SkyObjItem *soitem, QString type, QString infoText); 0108 void downloadWikipediaImage(SkyObjItem *soitem, QString imageURL); 0109 void inspectSkyObject(const QString& name); 0110 void inspectSkyObjectOnClick(SkyObject *obj); 0111 void inspectSkyObject(SkyObject *obj); 0112 bool inspectOnClickIsActive() { return inspectOnClick; } 0113 void updateObservingConditions(); 0114 void tryToUpdateWikipediaInfoInModel(bool onlyMissing); 0115 void refreshListView(); 0116 void updateProgress(double value); 0117 void setProgressBarVisible(bool visible); 0118 void setNightVisionOn(bool on); 0119 0120 private: 0121 QString getWikipediaName(SkyObjItem *soitem); 0122 0123 QQuickItem *m_BaseObj { nullptr }; 0124 QQuickItem *m_ViewsRowObj { nullptr }; 0125 QQuickItem *m_CategoryTitle { nullptr }; 0126 QQuickItem *m_SoListObj { nullptr }; 0127 QQuickItem *m_DetailsViewObj { nullptr }; 0128 QQuickItem *m_ProgressBar { nullptr }; 0129 QQuickItem *m_loadingMessage { nullptr }; 0130 QQuickItem *m_NextObj { nullptr }; 0131 QQuickItem *m_PrevObj { nullptr }; 0132 QQuickItem *m_CenterButtonObj { nullptr }; 0133 QQuickItem *m_SlewTelescopeButtonObj { nullptr }; 0134 QQuickItem *m_DetailsButtonObj { nullptr }; 0135 QQuickItem *inspectIconObj { nullptr }; 0136 QQuickItem *visibleIconObj { nullptr }; 0137 QQuickItem *favoriteIconObj { nullptr }; 0138 QQmlContext *m_Ctxt { nullptr }; 0139 QObject *infoBoxText { nullptr }; 0140 QObject *descTextObj { nullptr }; 0141 QObject *nightVision { nullptr }; 0142 QObject *autoTrackCheckbox { nullptr }; 0143 QObject *autoCenterCheckbox { nullptr }; 0144 0145 QQuickView *m_BaseView { nullptr }; 0146 ObsConditions *m_Obs { nullptr }; 0147 std::unique_ptr<ModelManager> m_ModManager; 0148 /// Current sky object item. 0149 SkyObjItem *m_CurSoItem { nullptr }; 0150 /// Created sky object item on-demand 0151 std::unique_ptr<SkyObjItem> trackedItem; 0152 /// Index of current sky-object item in Details view. 0153 int m_CurIndex { 0 }; 0154 /// Currently selected category from WI QML view 0155 QString m_CurrentObjectListName; 0156 std::unique_ptr<QNetworkAccessManager> manager; 0157 bool inspectOnClick { false }; 0158 };