File indexing completed on 2024-05-05 03:50:42
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Rene Kuettner <rene@bitkanal.net> 0004 // 0005 0006 #ifndef MARBLE_ECLIPSESPLUGIN_H 0007 #define MARBLE_ECLIPSESPLUGIN_H 0008 0009 #include "RenderPlugin.h" 0010 #include "DialogConfigurationInterface.h" 0011 0012 #include <QHash> 0013 0014 class QMenu; 0015 0016 namespace Ui { 0017 class EclipsesConfigDialog; 0018 class EclipsesReminderDialog; 0019 } 0020 0021 namespace Marble 0022 { 0023 0024 class MarbleWidget; 0025 class EclipsesModel; 0026 class EclipsesItem; 0027 class EclipsesBrowserDialog; 0028 0029 /** 0030 * @brief This plugin displays solar eclipses. 0031 * 0032 * It utilizes Gerhard Holtcamps eclsolar class to render nice 0033 * visualizations of eclipse events on earth. 0034 */ 0035 class EclipsesPlugin : public RenderPlugin, 0036 public DialogConfigurationInterface 0037 { 0038 Q_OBJECT 0039 Q_PLUGIN_METADATA(IID "org.kde.marble.EclipsesPlugin") 0040 0041 Q_INTERFACES( Marble::RenderPluginInterface ) 0042 Q_INTERFACES( Marble::DialogConfigurationInterface ) 0043 MARBLE_PLUGIN( EclipsesPlugin ) 0044 0045 public: 0046 EclipsesPlugin(); 0047 explicit EclipsesPlugin( const MarbleModel *marbleModel ); 0048 ~EclipsesPlugin() override; 0049 0050 // this is the implementation of the RenderPlugin interface 0051 // see RenderPlugin.h for a description 0052 0053 QStringList backendTypes() const override; 0054 QString renderPolicy() const override; 0055 QStringList renderPosition() const override; 0056 QString name() const override; 0057 QString nameId() const override; 0058 QString guiString() const override; 0059 QString version() const override; 0060 QString description() const override; 0061 QString copyrightYears() const override; 0062 QVector<PluginAuthor> pluginAuthors() const override; 0063 QIcon icon() const override; 0064 RenderPlugin::RenderType renderType() const override; 0065 QList<QActionGroup*>* actionGroups() const override; 0066 QDialog *configDialog() override; 0067 0068 void initialize() override; 0069 bool isInitialized() const override; 0070 0071 bool render( GeoPainter *painter, 0072 ViewportParams *viewport, 0073 const QString &renderPos, 0074 GeoSceneLayer *layer ) override; 0075 0076 QHash<QString, QVariant> settings() const override; 0077 void setSettings( const QHash<QString, QVariant> &settings ) override; 0078 0079 protected: 0080 bool eventFilter( QObject *object, QEvent *e ) override; 0081 0082 private Q_SLOTS: 0083 void readSettings(); 0084 void writeSettings(); 0085 void updateSettings(); 0086 0087 /** 0088 * @brief Update list of eclipses for the current year 0089 * 0090 * This calculates the list of eclipses for the year the marble clock 0091 * is set to. 0092 */ 0093 void updateEclipses(); 0094 0095 /** 0096 * @brief Show an eclipse event on the marble map 0097 * 0098 * @param year The year the eclipse event happens 0099 * @param index The index of the eclipse in this year 0100 * 0101 * Shows the eclipse with index @p index in year @p year by setting 0102 * the marble clock to the time of the eclipse's maximum. 0103 */ 0104 void showEclipse( int year, int index ); 0105 0106 /** 0107 * @brief Show an eclipse event selected from the menu 0108 * 0109 * @param action The menu items action 0110 * 0111 * Shows the eclipse the menu item given by @p action refers to. 0112 * The eclipse's index is stored in the actions data field while the 0113 * year is taken from the action's text. 0114 */ 0115 void showEclipseFromMenu( QAction *action ); 0116 0117 /** 0118 * @brief Update menu item state 0119 * 0120 * Updates the state of the plugin's menu items. They will be disabled for 0121 * non earth themes since we only support eclipse events on earth. 0122 */ 0123 void updateMenuItemState(); 0124 0125 private: 0126 bool renderItem( GeoPainter *painter, EclipsesItem *item ) const; 0127 0128 private: 0129 bool m_isInitialized; 0130 0131 MarbleWidget *m_marbleWidget; 0132 0133 EclipsesModel *m_model; 0134 QList<QActionGroup*> m_actionGroups; 0135 QActionGroup *m_eclipsesActionGroup; 0136 QHash<QString, QVariant> m_settings; 0137 QAction *m_eclipsesMenuAction; 0138 QMenu *m_eclipsesListMenu; 0139 int m_menuYear; 0140 0141 // dialogs 0142 QDialog *m_configDialog; 0143 Ui::EclipsesConfigDialog *m_configWidget; 0144 EclipsesBrowserDialog *m_browserDialog; 0145 QDialog *m_reminderDialog; 0146 Ui::EclipsesReminderDialog *m_reminderWidget; 0147 }; 0148 0149 } 0150 0151 #endif // MARBLE_ECLIPSESPLUGIN_H