Plasma
meter.h
Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2007 Petri Damsten <damu@iki.fi> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PLASMA_METER_H 00021 #define PLASMA_METER_H 00022 00023 #include <plasma/plasma_export.h> 00024 #include <plasma/dataengine.h> 00025 #include <QtGui/QGraphicsWidget> 00026 00027 namespace Plasma 00028 { 00029 00030 class MeterPrivate; 00031 00054 class PLASMA_EXPORT Meter : public QGraphicsWidget 00055 { 00056 Q_OBJECT 00057 Q_ENUMS(MeterType) 00058 Q_PROPERTY(int minimum READ minimum WRITE setMinimum) 00059 Q_PROPERTY(int maximum READ maximum WRITE setMaximum) 00060 Q_PROPERTY(int value READ value WRITE setValue) 00061 Q_PROPERTY(QString svg READ svg WRITE setSvg) 00062 Q_PROPERTY(MeterType meterType READ meterType WRITE setMeterType) 00063 00064 public: 00068 enum MeterType { 00070 BarMeterHorizontal, 00072 BarMeterVertical, 00074 AnalogMeter 00075 }; 00076 00082 explicit Meter(QGraphicsItem *parent = 0); 00083 00087 ~Meter(); 00088 00092 int maximum() const; 00093 00097 int minimum() const; 00098 00102 int value() const; 00103 00107 void setSvg(const QString &svg); 00108 00112 QString svg() const; 00113 00118 void setMeterType(MeterType type); 00119 00123 MeterType meterType() const; 00124 00130 void setLabel(int index, const QString &text); 00131 00136 QString label(int index) const; 00137 00143 void setLabelColor(int index, const QColor &color); 00144 00149 QColor labelColor(int index) const; 00150 00156 void setLabelFont(int index, const QFont &font); 00157 00162 QFont labelFont(int index) const; 00163 00169 void setLabelAlignment(int index, const Qt::Alignment alignment); 00170 00175 Qt::Alignment labelAlignment(int index) const; 00176 00181 QRectF labelRect(int index) const; 00182 00183 public Q_SLOTS: 00187 void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); 00188 00192 void setMaximum(int maximum); 00193 00197 void setMinimum(int minimum); 00198 00202 void setValue(int value); 00203 00204 protected: 00208 virtual void paint(QPainter *p, 00209 const QStyleOptionGraphicsItem *option, 00210 QWidget *widget = 0); 00211 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; 00212 00213 private: 00214 MeterPrivate *const d; 00215 }; 00216 00217 } // End of namepace 00218 00219 #endif
KDE 4.6 API Reference