weatherpopupapplet.h 3.33 KB
Newer Older
Petri Damstén's avatar
Petri Damstén committed
1
/*
Petri Damstén's avatar
Petri Damstén committed
2
 *   Copyright (C) 2009 Petri Damstén <damu@iki.fi>
Petri Damstén's avatar
Petri Damstén committed
3
 *
Petri Damstén's avatar
Petri Damstén committed
4 5 6 7
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
Petri Damstén's avatar
Petri Damstén committed
8
 *
Petri Damstén's avatar
Petri Damstén committed
9 10 11 12
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
Petri Damstén's avatar
Petri Damstén committed
13
 *
Petri Damstén's avatar
Petri Damstén committed
14 15 16 17
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Petri Damstén's avatar
Petri Damstén committed
18 19 20 21 22
 */

#ifndef WEATHERPOPUPAPPLET_HEADER
#define WEATHERPOPUPAPPLET_HEADER

23
#include <KUnitConversion/Unit>
24

Petri Damstén's avatar
Petri Damstén committed
25
#include <Plasma/DataEngine>
26
#include <Plasma/DataEngineConsumer>
27
#include <Plasma/Applet>
Petri Damstén's avatar
Petri Damstén committed
28 29 30

#include "plasmaweather_export.h"

31
namespace Plasma {
Petri Damstén's avatar
Petri Damstén committed
32

Petri Damstén's avatar
Petri Damstén committed
33 34 35 36 37
/**
 * @class WeatherPopupApplet <plasmaweather/weatherpopupapplet.h>
 *
 * @short Base class for Weather Applets
 */
38
class PLASMAWEATHER_EXPORT WeatherPopupApplet : public Plasma::Applet, public Plasma::DataEngineConsumer
Petri Damstén's avatar
Petri Damstén committed
39 40
{
    Q_OBJECT
41

Petri Damstén's avatar
Petri Damstén committed
42 43
    public:
        WeatherPopupApplet(QObject *parent, const QVariantList &args);
44
        ~WeatherPopupApplet() override;
Petri Damstén's avatar
Petri Damstén committed
45

46
    public: // Plasma::Applet API
Petri Damstén's avatar
Petri Damstén committed
47
        /**
48
         * Called once the applet is loaded and added to a Corona.
Petri Damstén's avatar
Petri Damstén committed
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
        void init() override;

        /**
         * Called when config is chnaged
         */
        void configChanged() override;

    public: // API to be implemented by subclasses
        /**
         * Used by QML config code, so check used keys carefully
         * @return currently used config values
         */
        Q_INVOKABLE virtual QVariantMap configValues() const;

    public Q_SLOTS: // API to be implemented by subclasses
        /**
         * Called when config is accepted
         * @param changedConfigValues config values which got changed
         */
        virtual void saveConfig(const QVariantMap& changedConfigValues);

        /**
         * Called when data is updated.
         * Method with this signature expected by connected dataengines.
         * Virtual, so subclasses can override it to also handle the data.
         */
        virtual void dataUpdated(const QString &name,
                                 const Plasma::DataEngine::Data &data);
78

79
    public:
Petri Damstén's avatar
Petri Damstén committed
80 81 82
        /**
         * @return pressure unit
         **/
83
        KUnitConversion::Unit pressureUnit() const;
84

Petri Damstén's avatar
Petri Damstén committed
85 86 87
        /**
         * @return temperature unit
         **/
88
        KUnitConversion::Unit temperatureUnit() const;
89

Petri Damstén's avatar
Petri Damstén committed
90 91 92
        /**
         * @return speed unit
         **/
93
        KUnitConversion::Unit speedUnit() const;
94

Petri Damstén's avatar
Petri Damstén committed
95 96 97
        /**
         * @return visibility unit
         **/
98
        KUnitConversion::Unit visibilityUnit() const;
Petri Damstén's avatar
Petri Damstén committed
99

Petri Damstén's avatar
Petri Damstén committed
100 101 102
        /**
         * @return condition icon with guessed value if it was empty
         **/
Petri Damstén's avatar
Petri Damstén committed
103 104
        QString conditionIcon();

105
        QString source() const;
106

107
    private:
Petri Damstén's avatar
Petri Damstén committed
108 109 110
        /**
         * Connects applet to dataengine
         */
111
        void connectToEngine();
Petri Damstén's avatar
Petri Damstén committed
112 113

    private:
114
        const QScopedPointer<class WeatherPopupAppletPrivate> d;
115

116
        friend class WeatherPopupAppletPrivate;
Petri Damstén's avatar
Petri Damstén committed
117 118
};

119 120
}

Petri Damstén's avatar
Petri Damstén committed
121
#endif