wiview.h 5.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/***************************************************************************
                          wiview.h  -  K Desktop Planetarium
                             -------------------
    begin                : 2012/26/05
    copyright            : (C) 2012 by Samikshan Bairagya
    email                : samikshan@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

18 19 20
#ifndef WIVIEW_H
#define WIVIEW_H

21 22
class QQuickView;
class QQuickItem;
23

24
#include <QQmlContext>
25 26 27
#include "skyobject.h"
#include "modelmanager.h"
#include "skyobjlistmodel.h"
28
#include "obsconditions.h"
29

30 31 32
/**
  * \class WIView
  * \brief Manages the QML user interface for What's Interesting.
33
  * WIView is used to display the QML UI using a QQuickView.
34 35 36 37
  * It acts on all signals emitted by the UI and manages the data
  * sent to the UI for display.
  * \author Samikshan Bairagya
  */
38
class WIView : public QWidget
39
{
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
        Q_OBJECT
    public:

        /**
          * \brief Constructor - Store QML components as QObject pointers.
          * Connect signals from various QML components into public slots.
          * Displays the user interface for What's Interesting
          */
        WIView(QWidget * parent = 0, ObsConditions * obs = 0);

        /**
          * \brief Destructor
          */
        ~WIView();

        /**
          * \brief Load details-view for selected sky-object
          */
        void loadDetailsView(SkyObjItem * soitem, int index);

        /**
          * \brief Updates sky-object list models
          */
        void updateModels(ObsConditions * obs);

        inline QQuickView * getWIBaseView() const
        {
            return m_BaseView;
        }

    public slots:

        /**
          * \brief public slot - Act upon signal emitted when category of sky-object is selected
          * from category selection view of the QML UI.
          * \param type Category selected
          */
        void onCategorySelected(int type);

        /**
          * \brief public slot - Act upon signal emitted when an item is selected from list of sky-objects.
          * Display details-view for the skyobject selected.
          * \param type        Category selected.
          * \param typename    Name of category selected.
          * \param index       Index of item in the list of skyobjects.
          */
        void onSoListItemClicked(int type, QString typeName, int index);

        /**
          * \brief public slot - Show details-view for next sky-object from list of current sky-objects's category.
          */
        void onNextObjClicked();

        /**
          * \brief public slot - Show details-view for previous sky-object from list of current sky-objects's category.
          */
        void onPrevObjClicked();

        /**
          * \brief public slot - Slew map to current sky-object in the details view.
          */
        void onSlewButtonClicked();

103 104 105 106 107
        /**
          * \brief public slot - Slew map to current sky-object in the details view.
          */
        void onSlewTelescopeButtonClicked();

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
        /**
          * \brief public slot - Open Details Dialog to show more details for current sky-object.
          */
        void onDetailsButtonClicked();

        /**
         * \brief public slot - Open WI settings dialog.
         */
        void onSettingsIconClicked();

        /**
         * \brief public slot - Reload list of visible sky-objects.
         */
        void onReloadIconClicked();

123 124
        void tryToLoadDescFromWikipedia(QObject * descTextObj, SkyObjItem * soitem);
        void loadObjectDescription(QObject * descTextObj, SkyObjItem * soitem);
125 126 127 128 129
        void tryToLoadInfoBoxFromWikipedia(QObject * infoBoxText, SkyObjItem * soitem);
        void loadObjectInfoBox(QObject * infoBoxText, SkyObjItem * soitem);
        void saveImageURL(SkyObjItem * soitem, QString imageURL);
        void saveObjectText(SkyObjItem * soitem, QString type, QString infoText);
        void downloadWikipediaImage(SkyObjItem * soitem, QString imageURL);
130 131


132 133
    private:
        QQuickItem * m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj,
134
                   *m_NextObj, *m_PrevObj, *m_SlewButtonObj, *m_SlewTelescopeButtonObj, *m_DetailsButtonObj;
135 136 137 138 139 140 141
        QQmlContext * m_Ctxt;
        QQuickView * m_BaseView;
        ObsConditions * m_Obs;
        ModelManager * m_ModManager;
        SkyObjItem * m_CurSoItem;  ///Current sky-object item.
        int m_CurIndex;            ///Index of current sky-object item in details-view.
        int m_CurCategorySelected; ///Currently selected category from WI QML view
142
};
143 144

#endif