knode
knrangefilter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef KNODE_KNRANGEFILTER_H
00016 #define KNODE_KNRANGEFILTER_H
00017
00018 #include <QGroupBox>
00019
00020 class QLabel;
00021 class KIntSpinBox;
00022 class QComboBox;
00023 class QCheckBox;
00024
00025 class KConfig;
00026
00027 namespace KNode {
00028
00030 class RangeFilter
00031 {
00032 friend class RangeFilterWidget;
00033
00034 public:
00035 RangeFilter() { op1=eq; op2=dis; val1=0; val2=0; enabled=false; }
00036 ~RangeFilter() {}
00037
00038 RangeFilter& operator=( const RangeFilter &nr )
00039 { val1=nr.val1; val2=nr.val2;
00040 op1=nr.op1; op2=nr.op2;
00041 enabled=nr.enabled;
00042 return (*this); }
00043
00044 void load(const KConfigGroup &conf);
00045 void save(KConfigGroup &conf);
00046
00047 bool doFilter(int a);
00048
00049 protected:
00050 enum Op { gt=0, gtoeq=1, eq=2, ltoeq=3, lt=4, dis=5 };
00051 bool matchesOp(int v1, Op o, int v2);
00052
00053 int val1, val2;
00054 Op op1, op2;
00055 bool enabled;
00056
00057 };
00058
00059
00060
00061
00062
00064 class RangeFilterWidget : public QGroupBox
00065 {
00066 Q_OBJECT
00067
00068 public:
00076 RangeFilterWidget( const QString& value, int min, int max, QWidget* parent,
00077 const QString &unit = QString() );
00078 ~RangeFilterWidget();
00079
00080 RangeFilter filter();
00081 void setFilter( RangeFilter &f );
00082 void clear();
00083
00084 protected:
00085 QCheckBox *enabled;
00086 QLabel *des;
00087 KIntSpinBox *val1, *val2;
00088 QComboBox *op1, *op2;
00089
00090 protected slots:
00091 void slotEnabled(bool e);
00092 void slotOp1Changed(int id);
00093 void slotOp2Changed(int id);
00094
00095 };
00096
00097 }
00098
00099 #endif // KNODE_KNRANGEFILTER_H