~ubuntu-branches/ubuntu/gutsy/kde4libs/gutsy

« back to all changes in this revision

Viewing changes to solid/solid/battery.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-02-21 11:00:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070221110012-6kw8khr9knv6lmg1
Tags: 3.80.3-0ubuntu1
New upstream unstable release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the KDE project
 
2
    Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License version 2 as published by the Free Software Foundation.
 
7
 
 
8
    This library is distributed in the hope that it will be useful,
 
9
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
    Library General Public License for more details.
 
12
 
 
13
    You should have received a copy of the GNU Library General Public License
 
14
    along with this library; see the file COPYING.LIB.  If not, write to
 
15
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
16
    Boston, MA 02110-1301, USA.
 
17
 
 
18
*/
 
19
 
 
20
#ifndef SOLID_BATTERY_H
 
21
#define SOLID_BATTERY_H
 
22
 
 
23
#include <kdelibs_export.h>
 
24
 
 
25
#include <solid/capability.h>
 
26
 
 
27
namespace Solid
 
28
{
 
29
    /**
 
30
     * This capability is available on batteries.
 
31
     */
 
32
    class SOLID_EXPORT Battery : public Capability
 
33
    {
 
34
        Q_OBJECT
 
35
        Q_ENUMS( BatteryType LevelType ChargeState )
 
36
        Q_PROPERTY( bool plugged READ isPlugged )
 
37
        Q_PROPERTY( BatteryType type READ type )
 
38
        Q_PROPERTY( QString chargeLevelUnit READ chargeLevelUnit )
 
39
        Q_PROPERTY( int charge READ charge )
 
40
        Q_PROPERTY( int chargePercent READ chargePercent )
 
41
        Q_PROPERTY( QString voltageUnit READ voltageUnit )
 
42
        Q_PROPERTY( int voltage READ voltage )
 
43
        Q_PROPERTY( bool rechargeable READ isRechargeable )
 
44
        Q_PROPERTY( ChargeState chargeState READ chargeState )
 
45
 
 
46
    public:
 
47
        /**
 
48
         * This enum type defines the type of the device holding the battery
 
49
         *
 
50
         * - PdaBattery : A battery in a Personal Digital Assistant
 
51
         * - UpsBattery : A battery in an Uninterruptible Power Supply
 
52
         * - PrimaryBattery : A primary battery for the system (for example laptop battery)
 
53
         * - MouseBattery : A battery in a mouse
 
54
         * - KeyboardBattery : A battery in a keyboard
 
55
         * - KeyboardMouseBattery : A battery in a combined keyboard and mouse
 
56
         * - CameraBattery : A battery in a camera
 
57
         * - UnknownBattery : A battery in an unknown device
 
58
         */
 
59
        enum BatteryType { UnknownBattery, PdaBattery, UpsBattery,
 
60
                           PrimaryBattery, MouseBattery, KeyboardBattery,
 
61
                           KeyboardMouseBattery, CameraBattery };
 
62
 
 
63
        /**
 
64
         * This enum type defines the kind of charge level a battery can expose
 
65
         *
 
66
         * - MaxLevel : The maximum charge level the battery got designed for
 
67
         * - LastFullLevel : The last charge level the battery got when full
 
68
         * - CurrentLevel : The current charge level
 
69
         * - WarningLevel : The battery is in 'warning' state below this level
 
70
         * - LowLevel : The battery is in 'low' state below this level
 
71
         */
 
72
        enum LevelType { MaxLevel, LastFullLevel, CurrentLevel,
 
73
                         WarningLevel, LowLevel };
 
74
 
 
75
        /**
 
76
         * This enum type defines charge state of a battery
 
77
         *
 
78
         * - NoCharge : Battery charge is stable, not charging or discharging
 
79
         * - Charging : Battery is charging
 
80
         * - Discharging : Battery is discharging
 
81
         */
 
82
        enum ChargeState { NoCharge, Charging, Discharging };
 
83
 
 
84
 
 
85
 
 
86
        /**
 
87
         * Creates a new Battery object.
 
88
         * You generally won't need this. It's created when necessary using
 
89
         * Device::as().
 
90
         *
 
91
         * @param backendObject the capability object provided by the backend
 
92
         * @see Solid::Device::as()
 
93
         */
 
94
        explicit Battery( QObject *backendObject );
 
95
 
 
96
        /**
 
97
         * Destroys a Battery object.
 
98
         */
 
99
        virtual ~Battery();
 
100
 
 
101
 
 
102
        /**
 
103
         * Get the Solid::Capability::Type of the Battery capability.
 
104
         *
 
105
         * @return the Battery capability type
 
106
         * @see Solid::Capability::Type
 
107
         */
 
108
        static Type capabilityType() { return Capability::Battery; }
 
109
 
 
110
        /**
 
111
         * Indicates if this battery is plugged.
 
112
         *
 
113
         * @return true if the battery is plugged, false otherwise
 
114
         */
 
115
        bool isPlugged() const;
 
116
 
 
117
        /**
 
118
         * Retrieves the type of device holding this battery.
 
119
         *
 
120
         * @return the type of device holding this battery
 
121
         * @see Solid::Battery::BatteryType
 
122
         */
 
123
        BatteryType type() const;
 
124
 
 
125
 
 
126
 
 
127
        /**
 
128
         * Retrieves the physical unit used by the charge level values
 
129
         * (for example mWh).
 
130
         *
 
131
         * @return the charge level unit as a string
 
132
         * @see charge()
 
133
         */
 
134
        QString chargeLevelUnit() const;
 
135
 
 
136
        /**
 
137
         * Retrieves one of the charge level of the battery as requested.
 
138
         * By default the current charge level is returned.
 
139
         *
 
140
         * The unit of the returned value is determined by chargeLevelUnit()
 
141
         *
 
142
         * @return the requested charge level
 
143
         * @see Solid::Battery::LevelType
 
144
         */
 
145
        int charge( LevelType type = CurrentLevel ) const;
 
146
 
 
147
        /**
 
148
         * Retrieves the current charge level of the battery normalised
 
149
         * to percent.
 
150
         *
 
151
         * @return the current charge level normalised to percent
 
152
         */
 
153
        int chargePercent() const;
 
154
 
 
155
 
 
156
 
 
157
        /**
 
158
         * Retrieves the physical unit used by the voltage values
 
159
         * (for example mV).
 
160
         *
 
161
         * @return the voltage level unit as a string
 
162
         * @see voltage()
 
163
         */
 
164
        QString voltageUnit() const;
 
165
 
 
166
        /**
 
167
         * Retrieves the current voltage level of the battery.
 
168
         *
 
169
         * The unit of the returned value is determined by voltageUnit()
 
170
         */
 
171
        int voltage() const;
 
172
 
 
173
 
 
174
 
 
175
        /**
 
176
         * Indicates if the battery is rechargeable.
 
177
         *
 
178
         * @return true if the battery is rechargeable, false otherwise (one time usage)
 
179
         */
 
180
        bool isRechargeable() const;
 
181
 
 
182
        /**
 
183
         * Retrieves the current charge state of the battery. It can be in a stable
 
184
         * state (no charge), charging or discharging.
 
185
         *
 
186
         * @return the current battery charge state
 
187
         * @see Solid::Battery::ChargeState
 
188
         */
 
189
        ChargeState chargeState() const;
 
190
 
 
191
    Q_SIGNALS:
 
192
        /**
 
193
         * This signal is emitted when the charge percent value of this
 
194
         * battery has changed.
 
195
         *
 
196
         * @param value the new charge percent value of the battery
 
197
         */
 
198
        void chargePercentChanged( int value );
 
199
 
 
200
        /**
 
201
         * This signal is emitted when the charge state of this battery
 
202
         * has changed.
 
203
         *
 
204
         * @param newState the new charge state of the battery, it's one of
 
205
         * the type Solid::Battery::ChargeState
 
206
         * @see Solid::Battery::ChargeState
 
207
         */
 
208
        void chargeStateChanged( int newState );
 
209
    };
 
210
}
 
211
 
 
212
#endif