Changeset View
Changeset View
Standalone View
Standalone View
src/KPropertyWidgetsFactory.h
Show All 14 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef KPROPERTYWIDGETS_FACTORY_H | 20 | #ifndef KPROPERTYWIDGETS_FACTORY_H | ||
21 | #define KPROPERTYWIDGETS_FACTORY_H | 21 | #define KPROPERTYWIDGETS_FACTORY_H | ||
22 | 22 | | |||
23 | #include "kpropertywidgets_export.h" | | |||
24 | #include "KProperty.h" | 23 | #include "KProperty.h" | ||
25 | #include "KPropertyFactory.h" | 24 | #include "KPropertyFactory.h" | ||
25 | #include "KPropertyUtils.h" | ||||
26 | 26 | | |||
27 | #include <QObject> | 27 | #include <QObject> | ||
28 | #include <QVariant> | 28 | #include <QVariant> | ||
29 | #include <QHash> | 29 | #include <QHash> | ||
30 | #include <QLabel> | 30 | #include <QLabel> | ||
31 | #include <QPainter> | 31 | #include <QPainter> | ||
32 | #include <QStyleOptionViewItem> | 32 | #include <QStyleOptionViewItem> | ||
33 | 33 | | |||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
77 | 77 | | |||
78 | //! Label widget that can be used for displaying text-based read-only items | 78 | //! Label widget that can be used for displaying text-based read-only items | ||
79 | //! Used in KPropertyLabelCreator. | 79 | //! Used in KPropertyLabelCreator. | ||
80 | class KPROPERTYWIDGETS_EXPORT KPropertyLabel : public QLabel | 80 | class KPROPERTYWIDGETS_EXPORT KPropertyLabel : public QLabel | ||
81 | { | 81 | { | ||
82 | Q_OBJECT | 82 | Q_OBJECT | ||
83 | Q_PROPERTY(QVariant value READ value WRITE setValue USER true) | 83 | Q_PROPERTY(QVariant value READ value WRITE setValue USER true) | ||
84 | public: | 84 | public: | ||
85 | KPropertyLabel(QWidget *parent, const KPropertyValueDisplayInterface *iface); | 85 | KPropertyLabel(QWidget *parent, const KProperty *property, const KPropertyValueDisplayInterface *iface); | ||
86 | QVariant value() const; | 86 | QVariant value() const; | ||
87 | Q_SIGNALS: | 87 | Q_SIGNALS: | ||
88 | void commitData( QWidget * editor ); | 88 | void commitData( QWidget * editor ); | ||
89 | public Q_SLOTS: | 89 | public Q_SLOTS: | ||
90 | void setValue(const QVariant& value); | 90 | void setValue(const QVariant& value); | ||
91 | 91 | | |||
92 | protected: | 92 | protected: | ||
93 | virtual void paintEvent( QPaintEvent * event ); | 93 | virtual void paintEvent( QPaintEvent * event ); | ||
94 | 94 | | |||
95 | private: | 95 | private: | ||
96 | const KProperty *m_property; | ||||
96 | const KPropertyValueDisplayInterface *m_iface; | 97 | const KPropertyValueDisplayInterface *m_iface; | ||
97 | QVariant m_value; | 98 | QVariant m_value; | ||
98 | }; | 99 | }; | ||
99 | 100 | | |||
100 | //! Creator returning editor | 101 | //! Creator returning editor | ||
101 | template<class Widget> | 102 | template<class Widget> | ||
102 | class KPROPERTYWIDGETS_EXPORT KPropertyEditorCreator : public KPropertyEditorCreatorInterface, | 103 | class KPROPERTYWIDGETS_EXPORT KPropertyEditorCreator : public KPropertyEditorCreatorInterface, | ||
103 | public KPropertyValueDisplayInterface, | 104 | public KPropertyValueDisplayInterface, | ||
104 | public KPropertyValuePainterInterface | 105 | public KPropertyValuePainterInterface | ||
105 | { | 106 | { | ||
106 | public: | 107 | public: | ||
107 | KPropertyEditorCreator() : KPropertyEditorCreatorInterface() {} | 108 | KPropertyEditorCreator() : KPropertyEditorCreatorInterface() {} | ||
108 | 109 | | |||
109 | virtual ~KPropertyEditorCreator() {} | 110 | virtual ~KPropertyEditorCreator() {} | ||
110 | 111 | | |||
111 | virtual QWidget * createEditor( int type, QWidget *parent, | 112 | virtual QWidget * createEditor( int type, QWidget *parent, | ||
112 | const QStyleOptionViewItem & option, const QModelIndex & index ) const | 113 | const QStyleOptionViewItem & option, const QModelIndex & index ) const | ||
113 | { | 114 | { | ||
114 | Q_UNUSED(type); | 115 | Q_UNUSED(type); | ||
115 | Q_UNUSED(option); | 116 | Q_UNUSED(option); | ||
116 | Q_UNUSED(index); | 117 | KProperty *prop = KPropertyUtils::propertyForIndex(index); | ||
117 | return new Widget(parent, this); | 118 | return new Widget(parent, prop, this); | ||
118 | } | 119 | } | ||
119 | 120 | | |||
120 | virtual void paint(QPainter *painter, | 121 | virtual void paint(QPainter *painter, | ||
121 | const QStyleOptionViewItem & option, const QModelIndex & index) const | 122 | const QStyleOptionViewItem & option, const QModelIndex & index) const | ||
122 | { | 123 | { | ||
123 | KPropertyValuePainterInterface::paint(this, painter, option, index); | 124 | KPropertyValuePainterInterface::paint(this, painter, option, index); | ||
124 | } | 125 | } | ||
125 | }; | 126 | }; | ||
Show All 35 Lines |