00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _ListView_h_
00025 #define _ListView_h_
00026
00027 #include <tqlistview.h>
00028 #include <tqpainter.h>
00029
00030 #include <SensorDisplay.h>
00031
00032 typedef const char* (*KeyFunc)(const char*);
00033
00034 class TQLabel;
00035 class QBoxGroup;
00036 class ListViewSettings;
00037
00038 class PrivateListView : public QListView
00039 {
00040 Q_OBJECT
00041 public:
00042 enum ColumnType { Text, Int, Float, Time, DiskStat };
00043
00044 PrivateListView(TQWidget *parent = 0, const char *name = 0);
00045
00046 void addColumn(const TQString& label, const TQString& type);
00047 void removeColumns(void);
00048 void update(const TQString& answer);
00049 int columnType( uint pos ) const;
00050
00051 private:
00052 TQStringList mColumnTypes;
00053 };
00054
00055 class PrivateListViewItem : public QListViewItem
00056 {
00057 public:
00058 PrivateListViewItem(PrivateListView *parent = 0);
00059
00060 void paintCell(TQPainter *p, const TQColorGroup &, int column, int width, int alignment) {
00061 TQColorGroup cgroup = _parent->colorGroup();
00062 TQListViewItem::paintCell(p, cgroup, column, width, alignment);
00063 p->setPen(cgroup.color(TQColorGroup::Link));
00064 p->drawLine(0, height() - 1, width - 1, height() - 1);
00065 }
00066
00067 void paintFocus(TQPainter *, const TQColorGroup, const TQRect) {}
00068
00069 virtual int compare( TQListViewItem*, int column, bool ascending ) const;
00070
00071 private:
00072 TQWidget *_parent;
00073 };
00074
00075 class ListView : public KSGRD::SensorDisplay
00076 {
00077 Q_OBJECT
00078 public:
00079 ListView(TQWidget* parent = 0, const char* name = 0,
00080 const TQString& = TQString::null, int min = 0, int max = 0);
00081 ~ListView() {}
00082
00083 bool addSensor(const TQString& hostName, const TQString& sensorName, const TQString& sensorType, const TQString& sensorDescr);
00084 void answerReceived(int id, const TQString& answer);
00085 void resizeEvent(TQResizeEvent*);
00086 void updateList();
00087
00088 bool restoreSettings(TQDomElement& element);
00089 bool saveSettings(TQDomDocument& doc, TQDomElement& element, bool save = true);
00090
00091 virtual bool hasSettingsDialog() const
00092 {
00093 return (true);
00094 }
00095
00096 virtual void timerEvent(TQTimerEvent*)
00097 {
00098 updateList();
00099 }
00100
00101 void configureSettings();
00102
00103 public slots:
00104 void applySettings();
00105 void applyStyle();
00106
00107 private:
00108 PrivateListView* monitor;
00109 ListViewSettings* lvs;
00110 };
00111
00112 #endif