|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #ifndef HBDATAFORMMODELITEM_H |
|
27 #define HBDATAFORMMODELITEM_H |
|
28 |
|
29 #include <Qt> |
|
30 #include <QMap> |
|
31 #include <QList> |
|
32 #include <QVariant> |
|
33 #include <QString> |
|
34 |
|
35 #include <hbglobal.h> |
|
36 |
|
37 class HbDataFormModelItemPrivate; |
|
38 class QAbstractItemModel; |
|
39 |
|
40 class HB_WIDGETS_EXPORT HbDataFormModelItem |
|
41 { |
|
42 |
|
43 public: |
|
44 |
|
45 enum Roles { |
|
46 KeyRole = Qt::UserRole + 1, |
|
47 LabelRole, |
|
48 ItemTypeRole, |
|
49 PropertyRole, |
|
50 DescriptionRole |
|
51 }; |
|
52 |
|
53 enum DataItemType { |
|
54 FormPageItem, |
|
55 GroupItem, |
|
56 GroupPageItem, |
|
57 SliderItem, |
|
58 VolumeSliderItem, |
|
59 CheckBoxItem, |
|
60 TextItem, |
|
61 ToggleValueItem, |
|
62 RadioButtonListItem, |
|
63 MultiselectionItem, |
|
64 ComboBoxItem, |
|
65 CustomItemBase = FormPageItem + 100, |
|
66 CustomItemEnd = CustomItemBase + 100 |
|
67 }; |
|
68 |
|
69 HbDataFormModelItem(HbDataFormModelItem::DataItemType type, |
|
70 const QString &label = QString(), |
|
71 const HbDataFormModelItem *parent = 0); |
|
72 explicit HbDataFormModelItem(const HbDataFormModelItem *parent = 0); |
|
73 virtual ~HbDataFormModelItem(); |
|
74 |
|
75 void appendChild(HbDataFormModelItem *child); |
|
76 void insertChild(int index, HbDataFormModelItem *child); |
|
77 void insertChildren(int startIndex, int count, QList<HbDataFormModelItem*> items); |
|
78 void removeChild(int index); |
|
79 void removeChildren(int startIndex, int count); |
|
80 |
|
81 HbDataFormModelItem* childAt(int index) const; |
|
82 int indexOf(const HbDataFormModelItem* child) const; |
|
83 int childCount() const; |
|
84 |
|
85 void setModel(const QAbstractItemModel *model); |
|
86 QAbstractItemModel* model() const; |
|
87 |
|
88 QVariant data(int role) const; |
|
89 void setData(int role, const QVariant &value); |
|
90 |
|
91 QVariant contentWidgetData(const QString &propertyName) const; |
|
92 QHash<QString, QVariant> contentWidgetData() const; |
|
93 void setContentWidgetData(const QString &propertyName, const QVariant &value); |
|
94 |
|
95 void setParent(HbDataFormModelItem* parent); |
|
96 HbDataFormModelItem* parent() const; |
|
97 |
|
98 void setType(HbDataFormModelItem::DataItemType type); |
|
99 HbDataFormModelItem::DataItemType type() const; |
|
100 |
|
101 void setLabel(const QString &label); |
|
102 QString label() const; |
|
103 |
|
104 void setDescription(const QString& description); |
|
105 QString description() const; |
|
106 |
|
107 void setIcon(const QString &icon); |
|
108 QString icon() const; |
|
109 |
|
110 void setEnabled(bool enabled); |
|
111 bool isEnabled() const; |
|
112 |
|
113 Qt::ItemFlags flags() const; |
|
114 |
|
115 protected: |
|
116 HbDataFormModelItemPrivate * const d_ptr; |
|
117 |
|
118 private: |
|
119 Q_DECLARE_PRIVATE_D(d_ptr, HbDataFormModelItem) |
|
120 }; |
|
121 #endif // HBDATAFORMMODELITEM_H |
|
122 |