KProperty

spinbox.h
1 /* This file is part of the KDE project
2  Copyright (C) 2004 Cedric Pasteur <[email protected]>
3  Copyright (C) 2004 Alexander Dymo <[email protected]>
4  Copyright (C) 2008-2017 Jarosław Staniek <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library 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 GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef KPROPERTY_SPINBOX_H
23 #define KPROPERTY_SPINBOX_H
24 
25 #include "KPropertyWidgetsFactory.h"
26 
27 #include <QSpinBox>
28 #include <QDoubleSpinBox>
29 
31 
34 class KPROPERTYWIDGETS_EXPORT KPropertyIntSpinBox : public QSpinBox
35 {
36  Q_OBJECT
37  Q_PROPERTY(QVariant value READ value WRITE setValue USER true)
38 
39 public:
40  KPropertyIntSpinBox(const KProperty& prop, QWidget *parent, int itemHeight);
41  ~KPropertyIntSpinBox() override;
42 
43  QVariant value() const;
44 
45 Q_SIGNALS:
46  void commitData(QWidget* editor);
47 
48 public Q_SLOTS:
49  void setValue(const QVariant& value);
50 
51 protected Q_SLOTS:
52  void slotValueChanged(int value);
53 
54 private:
56  class Private;
57  Private * const d;
58 };
59 
61 class KPROPERTYWIDGETS_EXPORT KPropertyDoubleSpinBox : public QDoubleSpinBox
62 {
63  Q_OBJECT
64  Q_PROPERTY(double value READ value WRITE setValue USER true)
65 
66 public:
67  KPropertyDoubleSpinBox(const KProperty &prop, QWidget *parent, int itemHeight);
68  ~KPropertyDoubleSpinBox() override;
69 
70 Q_SIGNALS:
71  void commitData(QWidget* editor);
72 
73 public Q_SLOTS:
74  void setValue(const QVariant& value);
75 
76 protected Q_SLOTS:
77  void slotValueChanged(double value);
78 
79 protected:
80  // keep this until the next ABI break
81  void resizeEvent( QResizeEvent * event ) override;
82 
84  class Private;
85  Private * const d;
86 };
87 
89 class KPROPERTYWIDGETS_EXPORT KPropertyIntSpinBoxDelegate : public KPropertyEditorCreatorInterface,
91 {
92 public:
94 
95  QString propertyValueToString(const KProperty *prop, const QLocale &locale) const override;
96 
97  QString valueToString(const QVariant &value, const QLocale &locale) const override;
98 
99  QWidget *createEditor(int type, QWidget *parent, const QStyleOptionViewItem &option,
100  const QModelIndex &index) const override;
101 };
102 
103 class KPROPERTYWIDGETS_EXPORT KPropertyDoubleSpinBoxDelegate : public KPropertyEditorCreatorInterface,
105 {
106 public:
107  KPropertyDoubleSpinBoxDelegate();
108 
109  QString propertyValueToString(const KProperty *prop, const QLocale &locale) const override;
110 
111  QString valueToString(const QVariant &value, const QLocale &locale) const override;
112 
113  QWidget *createEditor(int type, QWidget *parent, const QStyleOptionViewItem &option,
114  const QModelIndex &index) const override;
115 };
116 
117 #endif
A delegate supporting Int and UInt types.
Definition: spinbox.h:34
An interface for editor widget creators.
void setValue(double val)
Double editor.
Definition: spinbox.h:61
Q_PROPERTY(...)
The base class representing a single property.
Definition: KProperty.h:95
A delegate supporting Int, UInt, LongLong and ULongLong types.
Definition: spinbox.h:89
Q_DISABLE_COPY(Class)
virtual void resizeEvent(QResizeEvent *event) override
int value() const const
Provides a specialized conversion of value to string depending on type.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Aug 9 2020 23:10:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.