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

« back to all changes in this revision

Viewing changes to ksysguard/gui/WorkSheet.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) 1999 - 2002 Chris Schlaeger <cs@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 version 2 or at your option version 3 as published by
 
9
    the Free Software Foundation.
 
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 KSG_WORKSHEET_H
 
23
#define KSG_WORKSHEET_H
 
24
 
 
25
#include <QWidget>
 
26
#include <QTimer>
 
27
 
 
28
#include <SensorDisplay.h>
 
29
#include "SharedSettings.h"
 
30
 
 
31
class QDomElement;
 
32
class QDragEnterEvent;
 
33
class QDropEvent;
 
34
class QGridLayout;
 
35
class QString;
 
36
class QStringList;
 
37
 
 
38
/**
 
39
  A WorkSheet contains the displays to visualize the sensor results. When
 
40
  creating the WorkSheet you must specify the number of columns. Displays
 
41
  can be added and removed on the fly. The grid layout will handle the
 
42
  layout. The number of columns can not be changed. Displays are added by
 
43
  dragging a sensor from the sensor browser over the WorkSheet.
 
44
 */
 
45
class WorkSheet : public QWidget
 
46
{
 
47
  Q_OBJECT
 
48
 
 
49
  public:
 
50
    explicit WorkSheet( QWidget* parent);
 
51
    WorkSheet( int rows, int columns, float interval, QWidget* parent);
 
52
    ~WorkSheet();
 
53
 
 
54
    bool load( const QString &fileName );
 
55
    bool save( const QString &fileName );
 
56
    bool exportWorkSheet( const QString &fileName );
 
57
 
 
58
    void cut();
 
59
    void copy();
 
60
    void paste();
 
61
 
 
62
    void setFileName( const QString &fileName );
 
63
    QString fileName() const;
 
64
 
 
65
    QString fullFileName() const;
 
66
 
 
67
    bool isLocked() const {return mSharedSettings.locked;}
 
68
 
 
69
    QString title() const;
 
70
    QString translatedTitle() const;
 
71
    void refreshSheet();
 
72
 
 
73
    KSGRD::SensorDisplay* addDisplay( const QString &hostname,
 
74
                                      const QString &monitor,
 
75
                                      const QString &sensorType,
 
76
                                      const QString &sensorDescr,
 
77
                                      int index );
 
78
 
 
79
    void settings();
 
80
    float updateInterval() const;
 
81
 
 
82
  public Q_SLOTS:
 
83
    void showPopupMenu( KSGRD::SensorDisplay *display );
 
84
    void setTitle( const QString &title );
 
85
    void applyStyle();
 
86
 
 
87
  Q_SIGNALS:
 
88
    void titleChanged( QWidget *sheet );
 
89
 
 
90
  protected:
 
91
 
 
92
    virtual void changeEvent( QEvent * event );
 
93
    virtual QSize sizeHint() const;
 
94
    virtual void dragMoveEvent( QDragMoveEvent* );
 
95
    virtual void dragEnterEvent( QDragEnterEvent* );
 
96
    void dropEvent( QDropEvent* );
 
97
    bool event( QEvent* );
 
98
    void setUpdateInterval( float interval);
 
99
 
 
100
  private:
 
101
    void removeDisplay( KSGRD::SensorDisplay *display );
 
102
 
 
103
    bool replaceDisplay( int index, QDomElement& element );
 
104
 
 
105
    void replaceDisplay( int index,
 
106
                         KSGRD::SensorDisplay* display = 0 );
 
107
 
 
108
    void collectHosts( QStringList &list );
 
109
 
 
110
    void createGrid( int rows, int columns );
 
111
 
 
112
    void resizeGrid( int rows, int columns );
 
113
 
 
114
    KSGRD::SensorDisplay* currentDisplay( int *index = NULL);
 
115
 
 
116
    void fixTabOrder();
 
117
 
 
118
    QString currentDisplayAsXML();
 
119
 
 
120
    int mRows;
 
121
    int mColumns;
 
122
 
 
123
    QGridLayout* mGridLayout;
 
124
    QString mFileName;
 
125
    QString mFullFileName;
 
126
    QString mTitle;
 
127
    QString mTranslatedTitle;
 
128
 
 
129
    SharedSettings mSharedSettings;
 
130
 
 
131
    QTimer mTimer;
 
132
 
 
133
    enum DisplayType { DisplayDummy, DisplayFancyPlotter, DisplayMultiMeter, DisplayDancingBars, DisplaySensorLogger, DisplayListView, DisplayLogFile, DisplayProcessControllerRemote, DisplayProcessControllerLocal };
 
134
 
 
135
    KSGRD::SensorDisplay* insertDisplay( DisplayType displayType, QString displayTitle, int index);
 
136
    /**
 
137
      This two dimensional array stores the pointers to the sensor displays
 
138
            or if no sensor is present at a position a pointer to a dummy widget.
 
139
          The size of the array corresponds to the size of the grid layout.
 
140
     */
 
141
    QList <KSGRD::SensorDisplay*> mDisplayList;
 
142
};
 
143
 
 
144
#endif