1 /***************************************************************************
2  *                                                                         *
3  *   copyright : (C) 2007 The University of Toronto                        *
4  *                   netterfield@astro.utoronto.ca                         *
5  *                                                                         *
6  *   This program is free software; you can redistribute it and/or modify  *
7  *   it under the terms of the GNU General Public License as published by  *
8  *   the Free Software Foundation; either version 2 of the License, or     *
9  *   (at your option) any later version.                                   *
10  *                                                                         *
11  ***************************************************************************/
12 
13 #ifndef DATARANGE_H
14 #define DATARANGE_H
15 
16 #include <QWidget>
17 #include "ui_datarange.h"
18 
19 #include "kstwidgets_export.h"
20 
21 namespace Kst {
22 
23 //FIXME Need to add time related methods/functionality
24 
25 class  KSTWIDGETS_EXPORT DataRange : public QWidget, public Ui::DataRange {
26   Q_OBJECT
27   public:
28     explicit DataRange(QWidget *parent = 0);
29     virtual ~DataRange();
30 
31     qreal start() const;
32     bool startDirty() const;
33     void setStart(qreal start, bool callUpdateFields = true);
34 
35     QString startUnits() const;
36     int startUnitsIndex() const;
37     void setStartUnits(const QString &startUnits);
38 
39     qreal range() const;
40     bool rangeDirty() const;
41     void setRange(qreal range, bool callUpdateFields = true);
42 
43     qreal last() const;
44     bool lastDirty() const;
45     void setLast(qreal last, bool callUpdateFields = true);
46 
47     void updateIndexList(const QStringList &indexFields);
48     void clearIndexList();
49 
50     //FIXME Probably should be an enum...
51     QString rangeUnits() const;
52     int rangeUnitsIndex() const;
53     void setRangeUnits(const QString &rangeUnits);
54 
55     int skip() const;
56     bool skipDirty() const;
57     void setSkip(int skip);
58 
59     bool countFromEnd() const;
60     bool countFromEndDirty() const;
61     void setCountFromEnd(bool countFromEnd);
62 
63     bool readToEnd() const;
64     bool readToEndDirty() const;
65     void setReadToEnd(bool readToEnd);
66 
67     bool doSkip() const;
68     bool doSkipDirty() const;
69     void setDoSkip(bool doSkip);
70 
71     bool doFilter() const;
72     bool doFilterDirty() const;
73     void setDoFilter(bool doFilter);
74 
75     void clearValues();
76 
77     void setWidgetDefaults();
78     void loadWidgetDefaults();
79 
80     bool rangeIsValid();
81 
82     enum ControlField {Start, Last, Range, None};
83 
84     void updateFields(ControlField cf);
85   Q_SIGNALS:
86     void modified();
87 
88   private Q_SLOTS:
89     void countFromEndChanged();
90     void readToEndChanged();
91     void doSkipChanged();
92     void startChanged();
93     void lastChanged();
94     void rangeChanged();
95     void unitsChanged();
96 
97   private:
98     QString _requestedRangeUnits;
99     QString _requestedStartUnits;
100     ControlField _controlField0;
101     ControlField _controlField1;
102 };
103 
104 }
105 
106 #endif
107 
108 // vim: ts=2 sw=2 et
109