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

« back to all changes in this revision

Viewing changes to ksysguard/gui/SensorDisplayLib/SensorLogger.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) 2001 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 SENSORLOGGER_H
 
23
#define SENSORLOGGER_H
 
24
 
 
25
#include <QtGui/QTreeView>
 
26
 
 
27
#include <SensorDisplay.h>
 
28
 
 
29
class LogSensorModel;
 
30
class QDomElement;
 
31
 
 
32
class LogSensor : public QObject, public KSGRD::SensorClient
 
33
{
 
34
  Q_OBJECT
 
35
 
 
36
  public:
 
37
    explicit LogSensor( QObject *parent );
 
38
    ~LogSensor();
 
39
 
 
40
    virtual void answerReceived( int id, const QList<QByteArray>&answer );
 
41
 
 
42
    void setHostName( const QString& name );
 
43
    QString hostName() const;
 
44
 
 
45
    void setSensorName( const QString& name );
 
46
    QString sensorName() const;
 
47
 
 
48
    void setFileName( const QString& name );
 
49
    QString fileName() const;
 
50
 
 
51
    void setUpperLimitActive( bool value );
 
52
    bool upperLimitActive() const;
 
53
 
 
54
    void setLowerLimitActive( bool value );
 
55
    bool lowerLimitActive() const;
 
56
 
 
57
    void setUpperLimit( double value );
 
58
    double upperLimit() const;
 
59
 
 
60
    void setLowerLimit( double value );
 
61
    double lowerLimit() const;
 
62
 
 
63
    void setTimerInterval( int interval );
 
64
    int timerInterval() const;
 
65
 
 
66
    bool isLogging() const;
 
67
 
 
68
    bool limitReached() const;
 
69
 
 
70
  public Q_SLOTS:
 
71
    void timerOff();
 
72
    void timerOn();
 
73
 
 
74
    void startLogging();
 
75
    void stopLogging();
 
76
 
 
77
  Q_SIGNALS:
 
78
    void changed();
 
79
 
 
80
  protected:
 
81
    virtual void timerTick();
 
82
 
 
83
  private:
 
84
    QString mSensorName;
 
85
    QString mHostName;
 
86
    QString mFileName;
 
87
 
 
88
    int mTimerInterval;
 
89
    int mTimerID;
 
90
 
 
91
    bool mLowerLimitActive;
 
92
    bool mUpperLimitActive;
 
93
 
 
94
    double mLowerLimit;
 
95
    double mUpperLimit;
 
96
 
 
97
    bool mLimitReached;
 
98
};
 
99
 
 
100
class LogSensorView : public QTreeView
 
101
{
 
102
  Q_OBJECT
 
103
 
 
104
  public:
 
105
    LogSensorView( QWidget *parent = 0 );
 
106
 
 
107
  Q_SIGNALS:
 
108
    void contextMenuRequest( const QModelIndex &index, const QPoint &pos );
 
109
 
 
110
  protected:
 
111
    virtual void contextMenuEvent( QContextMenuEvent *event );
 
112
};
 
113
 
 
114
class SensorLogger : public KSGRD::SensorDisplay
 
115
{
 
116
  Q_OBJECT
 
117
 
 
118
  public:
 
119
    SensorLogger( QWidget *parent, const QString& title, SharedSettings *workSheetSettings );
 
120
    ~SensorLogger();
 
121
 
 
122
    bool addSensor( const QString& hostName, const QString& sensorName,
 
123
                    const QString& sensorType, const QString& sensorDescr);
 
124
 
 
125
    bool editSensor( LogSensor* );
 
126
 
 
127
    virtual void answerReceived( int, const QList<QByteArray>& );
 
128
 
 
129
    bool restoreSettings( QDomElement& );
 
130
    bool saveSettings( QDomDocument&, QDomElement& );
 
131
 
 
132
    void configureSettings();
 
133
 
 
134
    virtual bool hasSettingsDialog() const
 
135
    {
 
136
      return true;
 
137
    }
 
138
 
 
139
  public Q_SLOTS:
 
140
    void applyStyle();
 
141
    void contextMenuRequest( const QModelIndex &index, const QPoint &pos );
 
142
 
 
143
  private:
 
144
    LogSensorModel *mModel;
 
145
    LogSensorView *mView;
 
146
};
 
147
 
 
148
#endif