Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / ksysguard / gui / SensorDisplayLib / SensorModel.h
blobabb1d6d1d2421811f20e750b63c44d1bae592c17
1 /*
2 KSysGuard, the KDE System Guard
4 Copyright (c) 2006 Tobias Koenig <tokoe@kde.org>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef SENSORMODEL_H
23 #define SENSORMODEL_H
25 #include <QtCore/QAbstractTableModel>
26 #include <QtCore/QList>
27 #include <QtGui/QColor>
29 class SensorModelEntry
31 public:
32 typedef QList<SensorModelEntry> List;
34 void setId( int id );
35 int id() const;
37 void setHostName( const QString &hostName );
38 QString hostName() const;
40 void setSensorName( const QString &sensorName );
41 QString sensorName() const;
43 void setLabel( const QString &label );
44 QString label() const;
46 void setUnit( const QString &unit );
47 QString unit() const;
49 void setStatus( const QString &status );
50 QString status() const;
52 void setColor( const QColor &color );
53 QColor color() const;
55 private:
56 int mId;
57 QString mHostName;
58 QString mSensorName;
59 QString mLabel;
60 QString mUnit;
61 QString mStatus;
62 QColor mColor;
65 class SensorModel : public QAbstractTableModel
67 Q_OBJECT
68 public:
69 SensorModel( QObject *parent = 0 );
71 void setSensors( const SensorModelEntry::List &sensors );
72 SensorModelEntry::List sensors() const;
74 void setSensor( const SensorModelEntry &sensor, const QModelIndex &index );
75 void removeSensor( const QModelIndex &index );
76 SensorModelEntry sensor( const QModelIndex &index ) const;
78 void moveDownSensor(const QModelIndex &index);
79 void moveUpSensor(const QModelIndex &index);
80 void setHasLabel( bool hasLabel );
82 virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
83 virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
84 virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
85 virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
86 QList<int> order() const;
87 QList<int> deleted() const;
88 void clearDeleted();
89 void resetOrder();
91 private:
92 SensorModelEntry::List mSensors;
94 bool mHasLabel;
95 /** The numbers of the sensors to be deleted.*/
96 QList<int> mDeleted;
99 #endif