Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / ksysguard / gui / WorkSheet.h
blob16865cee4099aefc3e1e9b4fe2ed6020cab81597
1 /*
2 KSysGuard, the KDE System Guard
4 Copyright (c) 1999 - 2002 Chris Schlaeger <cs@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 version 2 or at your option version 3 as published by
9 the Free Software Foundation.
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 KSG_WORKSHEET_H
23 #define KSG_WORKSHEET_H
25 #include <QWidget>
26 #include <QTimer>
28 #include <SensorDisplay.h>
29 #include "SharedSettings.h"
31 class QDomElement;
32 class QDragEnterEvent;
33 class QDropEvent;
34 class QGridLayout;
35 class QString;
36 class QStringList;
37 class ProcessController;
39 /**
40 A WorkSheet contains the displays to visualize the sensor results. When
41 creating the WorkSheet you must specify the number of columns. Displays
42 can be added and removed on the fly. The grid layout will handle the
43 layout. The number of columns can not be changed. Displays are added by
44 dragging a sensor from the sensor browser over the WorkSheet.
46 class WorkSheet : public QWidget
48 Q_OBJECT
50 public:
51 explicit WorkSheet( QWidget* parent);
52 WorkSheet( uint rows, uint columns, uint interval, QWidget* parent);
53 ~WorkSheet();
55 bool load( const QString &fileName );
56 bool save( const QString &fileName );
57 bool exportWorkSheet( const QString &fileName );
59 void cut();
60 void copy();
61 void paste();
63 void setFileName( const QString &fileName );
64 QString fileName() const;
66 bool isLocked() const {return mSharedSettings.locked;}
68 QString title() const;
69 QString translatedTitle() const;
71 KSGRD::SensorDisplay* addDisplay( const QString &hostname,
72 const QString &monitor,
73 const QString &sensorType,
74 const QString &sensorDescr,
75 uint rows, uint columns );
77 void settings();
78 ProcessController *getLocalProcessController() const { return mLocalProcessController; }
80 public Q_SLOTS:
81 void showPopupMenu( KSGRD::SensorDisplay *display );
82 void setTitle( const QString &title );
83 void applyStyle();
85 Q_SIGNALS:
86 void titleChanged( QWidget *sheet );
88 protected:
90 virtual void changeEvent( QEvent * event );
91 virtual QSize sizeHint() const;
92 void dragEnterEvent( QDragEnterEvent* );
93 void dropEvent( QDropEvent* );
94 bool event( QEvent* );
95 void setUpdateInterval( unsigned int interval);
96 int updateInterval() const;
98 private:
99 void removeDisplay( KSGRD::SensorDisplay *display );
101 bool replaceDisplay( uint row, uint column, QDomElement& element );
103 void replaceDisplay( uint row, uint column,
104 KSGRD::SensorDisplay* display = 0 );
106 void collectHosts( QStringList &list );
108 void createGrid( uint rows, uint columns );
110 void resizeGrid( uint rows, uint columns );
112 KSGRD::SensorDisplay* currentDisplay( uint* row = 0, uint* column = 0 );
114 void fixTabOrder();
116 QString currentDisplayAsXML();
118 ProcessController *mLocalProcessController;
120 uint mRows;
121 uint mColumns;
123 QGridLayout* mGridLayout;
124 QString mFileName;
125 QString mTitle;
126 QString mTranslatedTitle;
128 SharedSettings mSharedSettings;
130 QTimer mTimer;
133 This two dimensional array stores the pointers to the sensor displays
134 or if no sensor is present at a position a pointer to a dummy widget.
135 The size of the array corresponds to the size of the grid layout.
137 KSGRD::SensorDisplay*** mDisplayList;
140 #endif