-rw-r--r-- | microkde/kdeui/knuminput.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/microkde/kdeui/knuminput.h b/microkde/kdeui/knuminput.h index 123fefa..9f9e200 100644 --- a/microkde/kdeui/knuminput.h +++ b/microkde/kdeui/knuminput.h | |||
@@ -8,48 +8,53 @@ | |||
8 | * Requires the Qt widget libraries, available at no cost at | 8 | * Requires the Qt widget libraries, available at no cost at |
9 | * http://www.troll.no/ | 9 | * http://www.troll.no/ |
10 | * | 10 | * |
11 | * This library is free software; you can redistribute it and/or | 11 | * This library is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Library General Public | 12 | * modify it under the terms of the GNU Library General Public |
13 | * License as published by the Free Software Foundation; either | 13 | * License as published by the Free Software Foundation; either |
14 | * version 2 of the License, or (at your option) any later version. | 14 | * version 2 of the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This library is distributed in the hope that it will be useful, | 16 | * This library is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public License | 21 | * You should have received a copy of the GNU Library General Public License |
22 | * along with this library; see the file COPYING.LIB. If not, write to | 22 | * along with this library; see the file COPYING.LIB. If not, write to |
23 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 23 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
24 | * Boston, MA 02111-1307, USA. | 24 | * Boston, MA 02111-1307, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef K_NUMINPUT_H | 27 | #ifndef K_NUMINPUT_H |
28 | #define K_NUMINPUT_H | 28 | #define K_NUMINPUT_H |
29 | 29 | ||
30 | #include <qwidget.h> | 30 | #include <qwidget.h> |
31 | #include <qspinbox.h> | 31 | #include <qspinbox.h> |
32 | #include <QLineEdit> | ||
33 | //Added by qt3to4: | ||
34 | #include <QResizeEvent> | ||
35 | #include <QLabel> | ||
36 | #include <QEvent> | ||
32 | 37 | ||
33 | class QLabel; | 38 | class QLabel; |
34 | class QSlider; | 39 | class QSlider; |
35 | class QLineEdit; | 40 | class QLineEdit; |
36 | class QLayout; | 41 | class QLayout; |
37 | class QValidator; | 42 | class QValidator; |
38 | 43 | ||
39 | class KIntSpinBox; | 44 | class KIntSpinBox; |
40 | 45 | ||
41 | /* ------------------------------------------------------------------------ */ | 46 | /* ------------------------------------------------------------------------ */ |
42 | 47 | ||
43 | /** | 48 | /** |
44 | * You need to inherit from this class if you want to implement K*NumInput | 49 | * You need to inherit from this class if you want to implement K*NumInput |
45 | * for a different variable type | 50 | * for a different variable type |
46 | * | 51 | * |
47 | */ | 52 | */ |
48 | class KNumInput : public QWidget | 53 | class KNumInput : public QWidget |
49 | { | 54 | { |
50 | Q_OBJECT | 55 | Q_OBJECT |
51 | Q_PROPERTY( QString label READ label WRITE setLabel ) | 56 | Q_PROPERTY( QString label READ label WRITE setLabel ) |
52 | public: | 57 | public: |
53 | /** | 58 | /** |
54 | * Default constructor | 59 | * Default constructor |
55 | * | 60 | * |
@@ -60,49 +65,49 @@ public: | |||
60 | * @param below A pointer to another KNumInput. | 65 | * @param below A pointer to another KNumInput. |
61 | * | 66 | * |
62 | */ | 67 | */ |
63 | KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0); | 68 | KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0); |
64 | ~KNumInput(); | 69 | ~KNumInput(); |
65 | 70 | ||
66 | /** | 71 | /** |
67 | * Sets the text and alignment of the main description label. | 72 | * Sets the text and alignment of the main description label. |
68 | * | 73 | * |
69 | * @param label The text of the label. | 74 | * @param label The text of the label. |
70 | * Use QString::null to remove an existing one. | 75 | * Use QString::null to remove an existing one. |
71 | * | 76 | * |
72 | * @param a one of @p AlignLeft, @p AlignHCenter, YAlignRight and | 77 | * @param a one of @p AlignLeft, @p AlignHCenter, YAlignRight and |
73 | * @p AlignTop, @p AlignVCenter, @p AlignBottom. | 78 | * @p AlignTop, @p AlignVCenter, @p AlignBottom. |
74 | * default is @p AlignLeft | @p AlignTop. | 79 | * default is @p AlignLeft | @p AlignTop. |
75 | * | 80 | * |
76 | * The vertical alignment flags have special meaning with this | 81 | * The vertical alignment flags have special meaning with this |
77 | * widget: | 82 | * widget: |
78 | * | 83 | * |
79 | * @li @p AlignTop The label is placed above the edit/slider | 84 | * @li @p AlignTop The label is placed above the edit/slider |
80 | * @li @p AlignVCenter The label is placed left beside the edit | 85 | * @li @p AlignVCenter The label is placed left beside the edit |
81 | * @li @p AlignBottom The label is placed below the edit/slider | 86 | * @li @p AlignBottom The label is placed below the edit/slider |
82 | * | 87 | * |
83 | */ | 88 | */ |
84 | virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); | 89 | virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop); |
85 | 90 | ||
86 | /** | 91 | /** |
87 | * @return the text of the label. | 92 | * @return the text of the label. |
88 | */ | 93 | */ |
89 | QString label() const; | 94 | QString label() const; |
90 | 95 | ||
91 | /** | 96 | /** |
92 | * @return if the num input has a slider. | 97 | * @return if the num input has a slider. |
93 | * @since 3.1 | 98 | * @since 3.1 |
94 | */ | 99 | */ |
95 | bool showSlider() const { return m_slider; } | 100 | bool showSlider() const { return m_slider; } |
96 | 101 | ||
97 | /** | 102 | /** |
98 | * Sets the spacing of tickmarks for the slider. | 103 | * Sets the spacing of tickmarks for the slider. |
99 | * | 104 | * |
100 | * @param minor Minor tickmark separation. | 105 | * @param minor Minor tickmark separation. |
101 | * @param major Major tickmark separation. | 106 | * @param major Major tickmark separation. |
102 | */ | 107 | */ |
103 | void setSteps(int minor, int major); | 108 | void setSteps(int minor, int major); |
104 | 109 | ||
105 | /** | 110 | /** |
106 | * Specifies that this widget may stretch horizontally, but is | 111 | * Specifies that this widget may stretch horizontally, but is |
107 | * fixed vertically (like @ref QSpinBox itself). | 112 | * fixed vertically (like @ref QSpinBox itself). |
108 | */ | 113 | */ |
@@ -281,49 +286,49 @@ public: | |||
281 | /** | 286 | /** |
282 | * @return the minimum value. | 287 | * @return the minimum value. |
283 | */ | 288 | */ |
284 | int minValue() const; | 289 | int minValue() const; |
285 | /** | 290 | /** |
286 | * Sets the maximum value. | 291 | * Sets the maximum value. |
287 | */ | 292 | */ |
288 | void setMaxValue(int max); | 293 | void setMaxValue(int max); |
289 | /** | 294 | /** |
290 | * @return the maximum value. | 295 | * @return the maximum value. |
291 | */ | 296 | */ |
292 | int maxValue() const; | 297 | int maxValue() const; |
293 | 298 | ||
294 | /** | 299 | /** |
295 | * Sets the special value text. If set, the SpinBox will display | 300 | * Sets the special value text. If set, the SpinBox will display |
296 | * this text instead of the numeric value whenever the current | 301 | * this text instead of the numeric value whenever the current |
297 | * value is equal to minVal(). Typically this is used for indicating | 302 | * value is equal to minVal(). Typically this is used for indicating |
298 | * that the choice has a special (default) meaning. | 303 | * that the choice has a special (default) meaning. |
299 | */ | 304 | */ |
300 | void setSpecialValueText(const QString& text); | 305 | void setSpecialValueText(const QString& text); |
301 | 306 | ||
302 | /** | 307 | /** |
303 | * @reimplemented | 308 | * @reimplemented |
304 | */ | 309 | */ |
305 | virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); | 310 | virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop); |
306 | 311 | ||
307 | /** | 312 | /** |
308 | * This method returns the minimum size necessary to display the | 313 | * This method returns the minimum size necessary to display the |
309 | * control. The minimum size is enough to show all the labels | 314 | * control. The minimum size is enough to show all the labels |
310 | * in the current font (font change may invalidate the return value). | 315 | * in the current font (font change may invalidate the return value). |
311 | * | 316 | * |
312 | * @return the minimum size necessary to show the control | 317 | * @return the minimum size necessary to show the control |
313 | */ | 318 | */ |
314 | virtual QSize minimumSizeHint() const; | 319 | virtual QSize minimumSizeHint() const; |
315 | 320 | ||
316 | public slots: | 321 | public slots: |
317 | /** | 322 | /** |
318 | * Sets the value of the control. | 323 | * Sets the value of the control. |
319 | */ | 324 | */ |
320 | void setValue(int); | 325 | void setValue(int); |
321 | 326 | ||
322 | /** | 327 | /** |
323 | * Sets the value in units of the @ref referencePoint | 328 | * Sets the value in units of the @ref referencePoint |
324 | * @since 3.1 | 329 | * @since 3.1 |
325 | */ | 330 | */ |
326 | void setRelativeValue(double); | 331 | void setRelativeValue(double); |
327 | 332 | ||
328 | /** | 333 | /** |
329 | * Sets the reference point for @ref relativeValue. | 334 | * Sets the reference point for @ref relativeValue. |
@@ -567,49 +572,49 @@ public: | |||
567 | 572 | ||
568 | /** | 573 | /** |
569 | * @return the reference point for @ref #relativeValue calculation | 574 | * @return the reference point for @ref #relativeValue calculation |
570 | * @since 3.1 | 575 | * @since 3.1 |
571 | */ | 576 | */ |
572 | double referencePoint() const; | 577 | double referencePoint() const; |
573 | 578 | ||
574 | /** | 579 | /** |
575 | * @return the current value in units of @ref #referencePoint. | 580 | * @return the current value in units of @ref #referencePoint. |
576 | * @since 3.1 | 581 | * @since 3.1 |
577 | */ | 582 | */ |
578 | double relativeValue() const; | 583 | double relativeValue() const; |
579 | 584 | ||
580 | /** | 585 | /** |
581 | * Sets the special value text. If set, the spin box will display | 586 | * Sets the special value text. If set, the spin box will display |
582 | * this text instead of the numeric value whenever the current | 587 | * this text instead of the numeric value whenever the current |
583 | * value is equal to @ref #minVal(). Typically this is used for indicating | 588 | * value is equal to @ref #minVal(). Typically this is used for indicating |
584 | * that the choice has a special (default) meaning. | 589 | * that the choice has a special (default) meaning. |
585 | */ | 590 | */ |
586 | void setSpecialValueText(const QString& text); | 591 | void setSpecialValueText(const QString& text); |
587 | 592 | ||
588 | /** | 593 | /** |
589 | * @reimplemented | 594 | * @reimplemented |
590 | */ | 595 | */ |
591 | virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); | 596 | virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop); |
592 | /** | 597 | /** |
593 | * @reimplemented | 598 | * @reimplemented |
594 | */ | 599 | */ |
595 | virtual QSize minimumSizeHint() const; | 600 | virtual QSize minimumSizeHint() const; |
596 | /** | 601 | /** |
597 | * @reimplemented | 602 | * @reimplemented |
598 | */ | 603 | */ |
599 | virtual bool eventFilter(QObject*, QEvent*); | 604 | virtual bool eventFilter(QObject*, QEvent*); |
600 | 605 | ||
601 | public slots: | 606 | public slots: |
602 | /** | 607 | /** |
603 | * Sets the value of the control. | 608 | * Sets the value of the control. |
604 | */ | 609 | */ |
605 | void setValue(double); | 610 | void setValue(double); |
606 | 611 | ||
607 | /** | 612 | /** |
608 | * Sets the value in units of @ref #referencePoint. | 613 | * Sets the value in units of @ref #referencePoint. |
609 | * @since 3.1 | 614 | * @since 3.1 |
610 | */ | 615 | */ |
611 | void setRelativeValue(double); | 616 | void setRelativeValue(double); |
612 | 617 | ||
613 | /** | 618 | /** |
614 | * Sets the reference Point to @p ref. It @p ref == 0, emitting of | 619 | * Sets the reference Point to @p ref. It @p ref == 0, emitting of |
615 | * @ref #relativeValueChanged is blocked and @ref #relativeValue | 620 | * @ref #relativeValueChanged is blocked and @ref #relativeValue |
@@ -737,48 +742,52 @@ public: | |||
737 | * @param name The Name of the widget. | 742 | * @param name The Name of the widget. |
738 | */ | 743 | */ |
739 | KIntSpinBox(int lower, int upper, int step, int value, int base = 10, | 744 | KIntSpinBox(int lower, int upper, int step, int value, int base = 10, |
740 | QWidget* parent = 0, const char* name = 0); | 745 | QWidget* parent = 0, const char* name = 0); |
741 | 746 | ||
742 | /** | 747 | /** |
743 | * Destructor. | 748 | * Destructor. |
744 | */ | 749 | */ |
745 | virtual ~KIntSpinBox(); | 750 | virtual ~KIntSpinBox(); |
746 | 751 | ||
747 | /** | 752 | /** |
748 | * Sets the base in which the numbers in the spin box are represented. | 753 | * Sets the base in which the numbers in the spin box are represented. |
749 | */ | 754 | */ |
750 | void setBase(int base); | 755 | void setBase(int base); |
751 | /** | 756 | /** |
752 | * @return the base in which numbers in the spin box are represented. | 757 | * @return the base in which numbers in the spin box are represented. |
753 | */ | 758 | */ |
754 | int base() const; | 759 | int base() const; |
755 | /** | 760 | /** |
756 | * sets focus and optionally marks all text | 761 | * sets focus and optionally marks all text |
757 | * | 762 | * |
758 | */ | 763 | */ |
759 | void setEditFocus(bool mark); | 764 | void setEditFocus(bool mark); |
760 | 765 | ||
766 | void setValidator(const QValidator *v) { | ||
767 | lineEdit()->setValidator(v); | ||
768 | } | ||
769 | |||
761 | protected: | 770 | protected: |
762 | 771 | ||
763 | /** | 772 | /** |
764 | * Overloaded the method in QSpinBox | 773 | * Overloaded the method in QSpinBox |
765 | * to make use of the base given in the constructor. | 774 | * to make use of the base given in the constructor. |
766 | */ | 775 | */ |
767 | virtual QString mapValueToText(int); | 776 | virtual QString mapValueToText(int); |
768 | 777 | ||
769 | /** | 778 | /** |
770 | * Overloaded the method in QSpinBox | 779 | * Overloaded the method in QSpinBox |
771 | * to make use of the base given in the constructor. | 780 | * to make use of the base given in the constructor. |
772 | */ | 781 | */ |
773 | virtual int mapTextToValue(bool*); | 782 | virtual int mapTextToValue(bool*); |
774 | 783 | ||
775 | private: | 784 | private: |
776 | int val_base; | 785 | int val_base; |
777 | protected: | 786 | protected: |
778 | virtual void virtual_hook( int id, void* data ); | 787 | virtual void virtual_hook( int id, void* data ); |
779 | private: | 788 | private: |
780 | class KIntSpinBoxPrivate; | 789 | class KIntSpinBoxPrivate; |
781 | KIntSpinBoxPrivate *d; | 790 | KIntSpinBoxPrivate *d; |
782 | }; | 791 | }; |
783 | 792 | ||
784 | 793 | ||