~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to ksysguard/gui/SensorDisplayLib/SensorModel.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    KSysGuard, the KDE System Guard
 
3
 
 
4
    Copyright (c) 2006 Tobias Koenig <tokoe@kde.org>
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.
 
19
 
 
20
*/
 
21
 
 
22
#ifndef SENSORMODEL_H
 
23
#define SENSORMODEL_H
 
24
 
 
25
#include <QtCore/QAbstractTableModel>
 
26
#include <QtCore/QList>
 
27
#include <QtGui/QColor>
 
28
 
 
29
class SensorModelEntry
 
30
{
 
31
  public:
 
32
    typedef QList<SensorModelEntry> List;
 
33
 
 
34
    void setId( int id );
 
35
    int id() const;
 
36
 
 
37
    void setHostName( const QString &hostName );
 
38
    QString hostName() const;
 
39
 
 
40
    void setSensorName( const QString &sensorName );
 
41
    QString sensorName() const;
 
42
 
 
43
    void setLabel( const QString &label );
 
44
    QString label() const;
 
45
 
 
46
    void setUnit( const QString &unit );
 
47
    QString unit() const;
 
48
 
 
49
    void setStatus( const QString &status );
 
50
    QString status() const;
 
51
 
 
52
    void setColor( const QColor &color );
 
53
    QColor color() const;
 
54
 
 
55
  private:
 
56
    int mId;
 
57
    QString mHostName;
 
58
    QString mSensorName;
 
59
    QString mLabel;
 
60
    QString mUnit;
 
61
    QString mStatus;
 
62
    QColor mColor;
 
63
};
 
64
 
 
65
class SensorModel : public QAbstractTableModel
 
66
{
 
67
  Q_OBJECT
 
68
  public:
 
69
    SensorModel( QObject *parent = 0 );
 
70
 
 
71
    void setSensors( const SensorModelEntry::List &sensors );
 
72
    SensorModelEntry::List sensors() const;
 
73
 
 
74
    void setSensor( const SensorModelEntry &sensor, const QModelIndex &index );
 
75
    void removeSensor( const QModelIndex &index );
 
76
    SensorModelEntry sensor( const QModelIndex &index ) const;
 
77
 
 
78
    void moveDownSensor(const QModelIndex &index);
 
79
    void moveUpSensor(const QModelIndex &index);
 
80
    void setHasLabel( bool hasLabel );
 
81
 
 
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();
 
90
 
 
91
  private:
 
92
    SensorModelEntry::List mSensors;
 
93
 
 
94
    bool mHasLabel;
 
95
    /** The numbers of the sensors to be deleted.*/
 
96
    QList<int> mDeleted;
 
97
};
 
98
 
 
99
#endif