21 #include <hbdataformmodel.h> |
21 #include <hbdataformmodel.h> |
22 #include <hbpushbutton.h> |
22 #include <hbpushbutton.h> |
23 #include <hblineedit.h> |
23 #include <hblineedit.h> |
24 #include <hbstyleloader.h> |
24 #include <hbstyleloader.h> |
25 #include <hbaction.h> |
25 #include <hbaction.h> |
|
26 #include <qinputcontext.h> |
|
27 #include <qapplication.h> |
26 |
28 |
27 #include "irviewmanager.h" |
29 #include "irviewmanager.h" |
28 #include "irapplication.h" |
30 #include "irapplication.h" |
29 #include "irplaycontroller.h" |
31 #include "irplaycontroller.h" |
30 #include "iropenwebaddressview.h" |
32 #include "iropenwebaddressview.h" |
33 #include "irqutility.h" |
35 #include "irqutility.h" |
34 #include "irqenums.h" |
36 #include "irqenums.h" |
35 #include "iruidefines.h" |
37 #include "iruidefines.h" |
36 #include "irqsettings.h" |
38 #include "irqsettings.h" |
37 static const int MAX_URL_CHARACTOR_NUMBER = 255; |
39 static const int MAX_URL_CHARACTOR_NUMBER = 255; |
|
40 static const int MAX_DATA_FORM_NUMBER_ROWS = 4; |
|
41 static const int MIN_DATA_FORM_NUMBER_ROWS = 1; |
38 |
42 |
39 IROpenWebAddressView::IROpenWebAddressView(IRApplication* aApplication, TIRViewId aViewId) : |
43 IROpenWebAddressView::IROpenWebAddressView(IRApplication* aApplication, TIRViewId aViewId) : |
40 IRBaseView(aApplication, aViewId), |
44 IRBaseView(aApplication, aViewId), |
41 iForm(NULL), |
45 iForm(NULL), |
42 iModel(NULL), |
46 iModel(NULL), |
47 { |
51 { |
48 //this view won't be starting view, don't need lazy init |
52 //this view won't be starting view, don't need lazy init |
49 IRBaseView::lazyInit(); |
53 IRBaseView::lazyInit(); |
50 setInitCompleted(true); |
54 setInitCompleted(true); |
51 |
55 |
52 // TODO: te be deleted if there's no difference between the landscape and portrait. |
56 // Listen to the orientation change event |
53 // connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ), |
57 connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ), |
54 // this, SLOT( handleOrientationChanged(Qt::Orientation) ) ); |
58 this, SLOT( handleOrientationChanged(Qt::Orientation) ) ); |
55 |
59 |
56 // Create widget hierarchy |
60 // Create widget hierarchy |
57 setObjectName(OPEN_WEB_ADDRESS_VIEW_OBJECT_VIEW); |
61 setObjectName(OPEN_WEB_ADDRESS_VIEW_OBJECT_VIEW); |
58 |
62 |
59 // List existing root elements - this allows us to refer to objects in the XML |
63 // List existing root elements - this allows us to refer to objects in the XML |
76 // get a new instance different from the base class. Because it's used in destructor and |
80 // get a new instance different from the base class. Because it's used in destructor and |
77 // the viewmanager is destructed after application, the base class iSettings is NULL before |
81 // the viewmanager is destructed after application, the base class iSettings is NULL before |
78 // destruct this class. |
82 // destruct this class. |
79 iSettings = IRQSettings::openInstance(); |
83 iSettings = IRQSettings::openInstance(); |
80 |
84 |
81 // Install event filter |
85 // Install event filter for Name |
82 QModelIndex index = iModel->indexFromItem(iName); |
86 QModelIndex index = iModel->indexFromItem(iName); |
83 HbAbstractViewItem* viewItem = iForm->itemByIndex(index); |
87 HbAbstractViewItem* viewItem = iForm->itemByIndex(index); |
84 HbDataFormViewItem* dataformviewitem = static_cast<HbDataFormViewItem *>(viewItem); |
88 HbDataFormViewItem* dataformviewitem = static_cast<HbDataFormViewItem *>(viewItem); |
85 HbWidget *widget = dataformviewitem->dataItemContentWidget(); |
89 HbWidget *widget = dataformviewitem->dataItemContentWidget(); |
86 iNameEditorPtr = static_cast<HbLineEdit *>(widget); |
90 iNameEditorPtr = static_cast<HbLineEdit *>(widget); |
87 iNameEditorPtr->installEventFilter(this); |
91 iNameEditorPtr->installEventFilter(this); |
88 |
92 |
|
93 //Install event filter for URL |
|
94 QModelIndex indexUrl = iModel->indexFromItem(iUrl); |
|
95 HbAbstractViewItem* viewItemUrl = iForm->itemByIndex(indexUrl); |
|
96 HbDataFormViewItem* dataformviewitemUrl = static_cast<HbDataFormViewItem *>(viewItemUrl); |
|
97 HbWidget *widgetUrl = dataformviewitemUrl->dataItemContentWidget(); |
|
98 iUrlEditorPtr = static_cast<HbLineEdit *>(widgetUrl); |
|
99 iUrlEditorPtr->installEventFilter(this); |
|
100 |
89 // Find the play button objects |
101 // Find the play button objects |
90 iPlayButton = qobject_cast<HbPushButton *>(iLoader.findObject(OPEN_WEB_ADDRESS_VIEW_OBJECT_PLAY_BUTTON)); |
102 iPlayButton = qobject_cast<HbPushButton *>(iLoader.findObject(OPEN_WEB_ADDRESS_VIEW_OBJECT_PLAY_BUTTON)); |
91 connect(iPlayButton, SIGNAL(released()), this, SLOT(play())); |
103 connect(iPlayButton, SIGNAL(released()), this, SLOT(play())); |
92 HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_CSS); |
104 HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_CSS); |
93 HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_WIDGETML); |
105 HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_WIDGETML); |
210 iUrl = new HbDataFormModelItem(HbDataFormModelItem::TextItem, hbTrId("txt_irad_formlabel_station_address")); |
222 iUrl = new HbDataFormModelItem(HbDataFormModelItem::TextItem, hbTrId("txt_irad_formlabel_station_address")); |
211 #else |
223 #else |
212 iUrl = new HbDataFormModelItem(HbDataFormModelItem::TextItem, hbTrId("Station address")); |
224 iUrl = new HbDataFormModelItem(HbDataFormModelItem::TextItem, hbTrId("Station address")); |
213 #endif |
225 #endif |
214 iUrl->setContentWidgetData("maxLength",MAX_URL_CHARACTOR_NUMBER); |
226 iUrl->setContentWidgetData("maxLength",MAX_URL_CHARACTOR_NUMBER); |
|
227 if (Qt::Horizontal == getViewManager()->orientation()) |
|
228 { |
|
229 iUrl->setContentWidgetData("maxRows", MIN_DATA_FORM_NUMBER_ROWS); |
|
230 } |
215 iModel->appendDataFormItem(iUrl); |
231 iModel->appendDataFormItem(iUrl); |
216 |
232 |
217 #ifdef SUBTITLE_STR_BY_LOCID |
233 #ifdef SUBTITLE_STR_BY_LOCID |
218 iName = new HbDataFormModelItem( |
234 iName = new HbDataFormModelItem( |
219 HbDataFormModelItem::TextItem, hbTrId("txt_irad_formlabel_station_name")); |
235 HbDataFormModelItem::TextItem, hbTrId("txt_irad_formlabel_station_name")); |
220 #else |
236 #else |
221 iName = new HbDataFormModelItem( |
237 iName = new HbDataFormModelItem( |
222 HbDataFormModelItem::TextItem, hbTrId("Station name")); |
238 HbDataFormModelItem::TextItem, hbTrId("Station name")); |
223 #endif |
239 #endif |
224 iName->setContentWidgetData("maxLength", MAX_URL_CHARACTOR_NUMBER); |
240 iName->setContentWidgetData("maxLength", MAX_URL_CHARACTOR_NUMBER); |
|
241 if (Qt::Horizontal == getViewManager()->orientation()) |
|
242 { |
|
243 iName->setContentWidgetData("maxRows", MIN_DATA_FORM_NUMBER_ROWS); |
|
244 } |
225 iModel->appendDataFormItem(iName); |
245 iModel->appendDataFormItem(iName); |
226 |
246 |
227 iForm->addConnection(iUrl, SIGNAL(textChanged(const QString&)), |
247 iForm->addConnection(iUrl, SIGNAL(textChanged(const QString&)), |
228 this, SLOT(urlEditorTextChanged(const QString&))); |
248 this, SLOT(urlEditorTextChanged(const QString&))); |
229 } |
249 } |
349 { |
371 { |
350 // Load the XML file |
372 // Load the XML file |
351 if (aOrientation == Qt::Vertical) |
373 if (aOrientation == Qt::Vertical) |
352 { |
374 { |
353 iLoader.load(OPEN_WEB_ADDRESS_VIEW_LAYOUT_FILENAME, "portrait"); |
375 iLoader.load(OPEN_WEB_ADDRESS_VIEW_LAYOUT_FILENAME, "portrait"); |
|
376 iUrl->setContentWidgetData("maxRows", MAX_DATA_FORM_NUMBER_ROWS); |
|
377 iName->setContentWidgetData("maxRows", MAX_DATA_FORM_NUMBER_ROWS); |
354 } |
378 } |
355 else |
379 else |
356 { |
380 { |
357 iLoader.load(OPEN_WEB_ADDRESS_VIEW_LAYOUT_FILENAME, "landscape"); |
381 iLoader.load(OPEN_WEB_ADDRESS_VIEW_LAYOUT_FILENAME, "landscape"); |
|
382 iUrl->setContentWidgetData("maxRows", MIN_DATA_FORM_NUMBER_ROWS); |
|
383 iName->setContentWidgetData("maxRows", MIN_DATA_FORM_NUMBER_ROWS); |
358 } |
384 } |
359 } |
385 } |
360 |
386 |
361 void IROpenWebAddressView::handleSettingAction() |
387 void IROpenWebAddressView::handleSettingAction() |
362 { |
388 { |