112 HbDataFormModelItem::ItemTypeRole).toInt()); |
114 HbDataFormModelItem::ItemTypeRole).toInt()); |
113 |
115 |
114 switch (itemType) { |
116 switch (itemType) { |
115 case CustomWidgetFrom: |
117 case CustomWidgetFrom: |
116 { |
118 { |
117 HbWidget *widgetTop = new HbWidget(); |
119 // Set the property so that the custom item layout |
118 QGraphicsLinearLayout *layoutTop = |
120 // will be the same for both portrait and landscape |
119 new QGraphicsLinearLayout(Qt::Horizontal); |
121 setProperty("expandItem", true); |
120 widgetTop->setLayout(layoutTop); |
122 // Create the widget |
|
123 HbWidget *widgetTop = new HbWidget(); |
|
124 QGraphicsLinearLayout *layoutTop = |
|
125 new QGraphicsLinearLayout(Qt::Horizontal); |
|
126 layoutTop->setContentsMargins(0, 0, 0, 0); |
|
127 |
|
128 widgetTop->setLayout(layoutTop); |
|
129 |
|
130 // Set the button spacing. |
|
131 HbDeviceProfile deviceProfile; |
|
132 // The layout guide specifies the spacing as 2 u. |
|
133 qreal spacing = deviceProfile.unitValue() * 2 ; |
|
134 layoutTop->setSpacing(spacing); |
|
135 // Calculate the button width. |
|
136 qreal right = 0.0; |
|
137 qreal left = 0.0; |
|
138 style()->parameter("hb-param-margin-gene-right", right); |
|
139 style()->parameter("hb-param-margin-gene-left", left); |
|
140 qreal screenWidth = 0.0; |
|
141 style()->parameter("hb-param-screen-short-edge", screenWidth); |
|
142 qreal buttonWidth = (screenWidth - right - left - spacing) / 2; |
121 |
143 |
122 mPushButtonTime = new HbPushButton(); |
144 mPushButtonTime = new HbPushButton(); |
|
145 mPushButtonTime->setPreferredWidth(buttonWidth); |
123 mPushButtonTime->setObjectName("startTime"); |
146 mPushButtonTime->setObjectName("startTime"); |
124 connect(mPushButtonTime, SIGNAL(clicked()), |
147 connect(mPushButtonTime, SIGNAL(clicked()), |
125 this, SLOT(handleTime())); |
148 this, SLOT(handleTime())); |
126 layoutTop->addItem(mPushButtonTime); |
149 layoutTop->addItem(mPushButtonTime); |
127 |
150 |
128 mPushButtonDate = |
151 mPushButtonDate = new HbPushButton(); |
129 new HbPushButton(); |
152 mPushButtonDate->setPreferredWidth(buttonWidth); |
130 mPushButtonDate->setObjectName("startDate"); |
153 mPushButtonDate->setObjectName("startDate"); |
131 connect(mPushButtonDate, SIGNAL(clicked()), |
154 connect(mPushButtonDate, SIGNAL(clicked()), |
132 this, SLOT(handleDate())); |
155 this, SLOT(handleDate())); |
133 layoutTop->addItem(mPushButtonDate); |
156 layoutTop->addItem(mPushButtonDate); |
134 OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
157 OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
135 return widgetTop; |
158 return widgetTop; |
136 } |
159 } |
137 |
160 |
138 |
161 |
139 case CustomWidgetTo: |
162 case CustomWidgetTo: |
140 { |
163 { |
141 HbWidget *widgetBottom = new HbWidget(); |
164 // Set the property so that the custom item layout |
142 QGraphicsLinearLayout *layoutBottom = |
165 // will be the same for both portrait and landscape |
143 new QGraphicsLinearLayout(Qt::Horizontal); |
166 setProperty("expandItem", true); |
144 widgetBottom->setLayout(layoutBottom); |
167 // Create the widget |
145 |
168 HbWidget *widgetBottom = new HbWidget(); |
146 mPushButtonTime = new HbPushButton(this); |
169 |
147 mPushButtonTime->setObjectName("endTime"); |
170 QGraphicsLinearLayout *layoutBottom = |
148 connect(mPushButtonTime, SIGNAL(clicked()), |
171 new QGraphicsLinearLayout(Qt::Horizontal); |
149 this, SLOT(handleTime())); |
172 layoutBottom->setContentsMargins(0, 0, 0, 0); |
150 layoutBottom->addItem(mPushButtonTime); |
173 widgetBottom->setLayout(layoutBottom); |
151 |
174 |
152 mPushButtonDate = new HbPushButton(this); |
175 // Set the button spacing. |
153 mPushButtonDate->setObjectName("endDate"); |
176 HbDeviceProfile deviceProfile; |
154 connect(mPushButtonDate, SIGNAL(clicked()), |
177 // The layout guide specifies the spacing as 2 u. |
155 this, SLOT(handleDate())); |
178 qreal spacing = deviceProfile.unitValue() * 2 ; |
156 layoutBottom->addItem(mPushButtonDate); |
179 layoutBottom->setSpacing(spacing); |
|
180 // Calculate the button width. |
|
181 qreal right = 0.0; |
|
182 qreal left = 0.0; |
|
183 style()->parameter("hb-param-margin-gene-right", right); |
|
184 style()->parameter("hb-param-margin-gene-left", left); |
|
185 qreal screenWidth = 0.0; |
|
186 style()->parameter("hb-param-screen-short-edge", screenWidth); |
|
187 qreal buttonWidth = (screenWidth - right - left - spacing) / 2; |
|
188 |
|
189 mPushButtonTime = new HbPushButton(this); |
|
190 mPushButtonTime->setPreferredWidth(buttonWidth); |
|
191 mPushButtonTime->setObjectName("endTime"); |
|
192 connect(mPushButtonTime, SIGNAL(clicked()), |
|
193 this, SLOT(handleTime())); |
|
194 layoutBottom->addItem(mPushButtonTime); |
|
195 |
|
196 mPushButtonDate = new HbPushButton(this); |
|
197 mPushButtonDate->setPreferredWidth(buttonWidth); |
|
198 mPushButtonDate->setObjectName("endDate"); |
|
199 connect(mPushButtonDate, SIGNAL(clicked()), |
|
200 this, SLOT(handleDate())); |
|
201 layoutBottom->addItem(mPushButtonDate); |
157 OstTraceFunctionExit0( DUP1_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
202 OstTraceFunctionExit0( DUP1_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
158 return widgetBottom; |
203 return widgetBottom; |
159 } |
204 } |
160 |
205 |
161 case CustomWidgetLocation: |
206 case CustomWidgetLocation: |
162 { |
207 { |
163 CalenEditorDocLoader editorLocationDocLoader; |
208 setProperty("expandItem", false); |
164 bool loadSuccess = false; |
209 HbWidget *widgetLocation = new HbWidget(); |
165 |
210 QGraphicsLinearLayout *layoutLocation = |
166 editorLocationDocLoader.load(CALEN_EDITOR_LOCATION_XML_FILE, |
211 new QGraphicsLinearLayout(Qt::Horizontal); |
167 &loadSuccess); |
212 layoutLocation->setContentsMargins(0, 0, 0, 0); |
168 Q_ASSERT_X(loadSuccess, "caleneditor.cpp", |
213 widgetLocation->setLayout(layoutLocation); |
169 "Unable to load caleneditor location view XML"); |
214 |
170 HbWidget* widgetLocation = qobject_cast<HbWidget *> ( |
215 // Set the spacing between LineEdit and PushButton |
171 editorLocationDocLoader.findWidget(CALEN_EDITOR_LOCATION)); |
216 qreal spacing = 0.0; |
172 |
217 style()->parameter( |
173 mLocationLineEdit = qobject_cast<HbLineEdit *>( |
218 "hb-param-margin-gene-middle-horizontal", spacing); |
174 editorLocationDocLoader.findWidget( |
219 layoutLocation->setSpacing(spacing); |
175 CALEN_EDITOR_LOCATION_LINEEDIT)); |
220 |
|
221 mLocationLineEdit = new HbLineEdit(this); |
176 mLocationLineEdit->setObjectName("locationLineEdit"); |
222 mLocationLineEdit->setObjectName("locationLineEdit"); |
177 mLocationLineEdit->setMinRows(1); |
|
178 mLocationLineEdit->setMaxRows(MaxRowsInTextItem); |
223 mLocationLineEdit->setMaxRows(MaxRowsInTextItem); |
179 mLocationPushButton = qobject_cast<HbPushButton*>( |
224 connect(mLocationLineEdit, SIGNAL(textChanged(const QString)), |
180 editorLocationDocLoader.findWidget( |
225 this, SLOT(handleLocationTextChange(const QString))); |
181 CALEN_EDITOR_LOCATION_PUSHBUTTON)); |
226 connect(mLocationLineEdit, SIGNAL(editingFinished()), |
|
227 this, SLOT(handleEditingFinished())); |
|
228 layoutLocation->addItem(mLocationLineEdit); |
|
229 |
|
230 mLocationPushButton = new HbPushButton(this); |
|
231 |
|
232 HbDeviceProfile deviceProfile; |
|
233 // The layout guide specifies the spacing as 9.5 u |
|
234 // and the height as 7.4 u |
|
235 qreal width = deviceProfile.unitValue() * 9.5; |
|
236 qreal height = deviceProfile.unitValue() * 7.4 ; |
|
237 mLocationPushButton->setPreferredSize(width, height); |
|
238 mLocationPushButton->setSizePolicy( |
|
239 QSizePolicy::Fixed, QSizePolicy::Fixed); |
|
240 mLocationPushButton->setIcon( HbIcon("qtg_mono_location")); |
182 mLocationPushButton->setObjectName("locationIcon"); |
241 mLocationPushButton->setObjectName("locationIcon"); |
183 mLocationPushButton->setIcon( HbIcon("qtg_mono_location")); |
|
184 |
|
185 connect(mLocationPushButton, SIGNAL(clicked()), this, |
242 connect(mLocationPushButton, SIGNAL(clicked()), this, |
186 SLOT(launchLocationPicker())); |
243 SLOT(launchLocationPicker())); |
187 connect(mLocationLineEdit, SIGNAL(textChanged(const QString)), |
244 layoutLocation->addItem(mLocationPushButton); |
188 this, SLOT(handleLocationTextChange(const QString))); |
|
189 |
|
190 connect(mLocationLineEdit, SIGNAL(editingFinished()), |
|
191 this, SLOT(handleEditingFinished())); |
|
192 |
|
193 OstTraceFunctionExit0( DUP2_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
245 OstTraceFunctionExit0( DUP2_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
194 return widgetLocation; |
246 return widgetLocation; |
195 } |
247 } |
196 |
248 |
197 case RepeatUntilOffset: |
249 case RepeatUntilOffset: |
198 { |
250 { |
199 mRepeatUntilWidget = new HbPushButton(this); |
251 setProperty("expandItem", false); |
200 mRepeatUntilWidget->setObjectName("repeatUntilItem"); |
252 mRepeatUntilWidget = new HbPushButton(this); |
201 OstTraceFunctionExit0( DUP3_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
253 mRepeatUntilWidget->setObjectName("repeatUntilItem"); |
202 return mRepeatUntilWidget; |
254 OstTraceFunctionExit0( DUP3_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
|
255 return mRepeatUntilWidget; |
203 } |
256 } |
204 |
257 |
205 case ReminderTimeOffset: |
258 case ReminderTimeOffset: |
206 { |
259 { |
|
260 setProperty("expandItem", false); |
207 mReminderTimeWidget = new HbPushButton(this); |
261 mReminderTimeWidget = new HbPushButton(this); |
208 mReminderTimeWidget->setObjectName("remainderTimeItem"); |
262 mReminderTimeWidget->setObjectName("remainderTimeItem"); |
209 OstTraceFunctionExit0( DUP4_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
263 OstTraceFunctionExit0( DUP4_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
210 return mReminderTimeWidget; |
264 return mReminderTimeWidget; |
211 } |
265 } |