KProperty

spinbox.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net>
4 Copyright (C) 2008-2017 Jarosław Staniek <staniek@kde.org>
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
30//! A delegate supporting Int and UInt types
31/*! Note that due to KIntNumInput limitations, for UInt the maximum value
32 is INT_MAX, not UINT_MAX.
33*/
34class KPROPERTYWIDGETS_EXPORT KPropertyIntSpinBox : public QSpinBox
35{
36 Q_OBJECT
37 Q_PROPERTY(QVariant value READ value WRITE setValue USER true)
38
39public:
40 KPropertyIntSpinBox(const KProperty& prop, QWidget *parent, int itemHeight);
41 ~KPropertyIntSpinBox() override;
42
43 QVariant value() const;
44
46 void commitData(QWidget* editor);
47
48public Q_SLOTS:
49 void setValue(const QVariant& value);
50
51protected Q_SLOTS:
52 void slotValueChanged(int value);
53
54private:
55 Q_DISABLE_COPY(KPropertyIntSpinBox)
56 class Private;
57 Private * const d;
58};
59
60//! Double editor
61class KPROPERTYWIDGETS_EXPORT KPropertyDoubleSpinBox : public QDoubleSpinBox
62{
63 Q_OBJECT
64 Q_PROPERTY(double value READ value WRITE setValue USER true)
65
66public:
67 KPropertyDoubleSpinBox(const KProperty &prop, QWidget *parent, int itemHeight);
68 ~KPropertyDoubleSpinBox() override;
69
71 void commitData(QWidget* editor);
72
73public Q_SLOTS:
74 void setValue(const QVariant& value);
75
76protected Q_SLOTS:
77 void slotValueChanged(double value);
78
79protected:
80 // keep this until the next ABI break
81 void resizeEvent( QResizeEvent * event ) override;
82
83 Q_DISABLE_COPY(KPropertyDoubleSpinBox)
84 class Private;
85 Private * const d;
86};
87
88//! A delegate supporting Int, UInt, LongLong and ULongLong types
89class KPROPERTYWIDGETS_EXPORT KPropertyIntSpinBoxDelegate : public KPropertyEditorCreatorInterface,
91{
92public:
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
103class KPROPERTYWIDGETS_EXPORT KPropertyDoubleSpinBoxDelegate : public KPropertyEditorCreatorInterface,
105{
106public:
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
Double editor.
Definition spinbox.h:62
An interface for editor widget creators.
A delegate supporting Int, UInt, LongLong and ULongLong types.
Definition spinbox.h:91
A delegate supporting Int and UInt types.
Definition spinbox.h:35
Provides a specialized conversion of value to string depending on type.
The base class representing a single property.
Definition KProperty.h:96
virtual void resizeEvent(QResizeEvent *event) override
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:12:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.