diff -r ef813d54df51 -r a5a1242fd2e8 calendarui/caleneditor/src/caleneditorcustomitem.cpp --- a/calendarui/caleneditor/src/caleneditorcustomitem.cpp Wed Aug 18 09:47:38 2010 +0300 +++ b/calendarui/caleneditor/src/caleneditorcustomitem.cpp Thu Sep 02 20:25:23 2010 +0300 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,7 @@ mRequestPending(false) { OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_CALENEDITORCUSTOMITEM_ENTRY ); + HbStyleLoader::registerFilePath(":/xml"); mMinDate = CalenDateUtils::minTime().date(); mMaxDate = CalenDateUtils::maxTime().date(); mMinTime.setHMS(0,0,0,0); @@ -114,22 +116,43 @@ switch (itemType) { case CustomWidgetFrom: { - HbWidget *widgetTop = new HbWidget(); - QGraphicsLinearLayout *layoutTop = - new QGraphicsLinearLayout(Qt::Horizontal); - widgetTop->setLayout(layoutTop); + // Set the property so that the custom item layout + // will be the same for both portrait and landscape + setProperty("expandItem", true); + // Create the widget + HbWidget *widgetTop = new HbWidget(); + QGraphicsLinearLayout *layoutTop = + new QGraphicsLinearLayout(Qt::Horizontal); + layoutTop->setContentsMargins(0, 0, 0, 0); + + widgetTop->setLayout(layoutTop); + + // Set the button spacing. + HbDeviceProfile deviceProfile; + // The layout guide specifies the spacing as 2 u. + qreal spacing = deviceProfile.unitValue() * 2 ; + layoutTop->setSpacing(spacing); + // Calculate the button width. + qreal right = 0.0; + qreal left = 0.0; + style()->parameter("hb-param-margin-gene-right", right); + style()->parameter("hb-param-margin-gene-left", left); + qreal screenWidth = 0.0; + style()->parameter("hb-param-screen-short-edge", screenWidth); + qreal buttonWidth = (screenWidth - right - left - spacing) / 2; mPushButtonTime = new HbPushButton(); + mPushButtonTime->setPreferredWidth(buttonWidth); mPushButtonTime->setObjectName("startTime"); connect(mPushButtonTime, SIGNAL(clicked()), - this, SLOT(handleTime())); + this, SLOT(handleTime())); layoutTop->addItem(mPushButtonTime); - mPushButtonDate = - new HbPushButton(); + mPushButtonDate = new HbPushButton(); + mPushButtonDate->setPreferredWidth(buttonWidth); mPushButtonDate->setObjectName("startDate"); connect(mPushButtonDate, SIGNAL(clicked()), - this, SLOT(handleDate())); + this, SLOT(handleDate())); layoutTop->addItem(mPushButtonDate); OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); return widgetTop; @@ -138,72 +161,103 @@ case CustomWidgetTo: { - HbWidget *widgetBottom = new HbWidget(); - QGraphicsLinearLayout *layoutBottom = - new QGraphicsLinearLayout(Qt::Horizontal); - widgetBottom->setLayout(layoutBottom); + // Set the property so that the custom item layout + // will be the same for both portrait and landscape + setProperty("expandItem", true); + // Create the widget + HbWidget *widgetBottom = new HbWidget(); + + QGraphicsLinearLayout *layoutBottom = + new QGraphicsLinearLayout(Qt::Horizontal); + layoutBottom->setContentsMargins(0, 0, 0, 0); + widgetBottom->setLayout(layoutBottom); - mPushButtonTime = new HbPushButton(this); - mPushButtonTime->setObjectName("endTime"); - connect(mPushButtonTime, SIGNAL(clicked()), - this, SLOT(handleTime())); - layoutBottom->addItem(mPushButtonTime); - - mPushButtonDate = new HbPushButton(this); - mPushButtonDate->setObjectName("endDate"); - connect(mPushButtonDate, SIGNAL(clicked()), - this, SLOT(handleDate())); - layoutBottom->addItem(mPushButtonDate); + // Set the button spacing. + HbDeviceProfile deviceProfile; + // The layout guide specifies the spacing as 2 u. + qreal spacing = deviceProfile.unitValue() * 2 ; + layoutBottom->setSpacing(spacing); + // Calculate the button width. + qreal right = 0.0; + qreal left = 0.0; + style()->parameter("hb-param-margin-gene-right", right); + style()->parameter("hb-param-margin-gene-left", left); + qreal screenWidth = 0.0; + style()->parameter("hb-param-screen-short-edge", screenWidth); + qreal buttonWidth = (screenWidth - right - left - spacing) / 2; + + mPushButtonTime = new HbPushButton(this); + mPushButtonTime->setPreferredWidth(buttonWidth); + mPushButtonTime->setObjectName("endTime"); + connect(mPushButtonTime, SIGNAL(clicked()), + this, SLOT(handleTime())); + layoutBottom->addItem(mPushButtonTime); + + mPushButtonDate = new HbPushButton(this); + mPushButtonDate->setPreferredWidth(buttonWidth); + mPushButtonDate->setObjectName("endDate"); + connect(mPushButtonDate, SIGNAL(clicked()), + this, SLOT(handleDate())); + layoutBottom->addItem(mPushButtonDate); OstTraceFunctionExit0( DUP1_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); - return widgetBottom; + return widgetBottom; } case CustomWidgetLocation: { - CalenEditorDocLoader editorLocationDocLoader; - bool loadSuccess = false; - - editorLocationDocLoader.load(CALEN_EDITOR_LOCATION_XML_FILE, - &loadSuccess); - Q_ASSERT_X(loadSuccess, "caleneditor.cpp", - "Unable to load caleneditor location view XML"); - HbWidget* widgetLocation = qobject_cast ( - editorLocationDocLoader.findWidget(CALEN_EDITOR_LOCATION)); - - mLocationLineEdit = qobject_cast( - editorLocationDocLoader.findWidget( - CALEN_EDITOR_LOCATION_LINEEDIT)); + setProperty("expandItem", false); + HbWidget *widgetLocation = new HbWidget(); + QGraphicsLinearLayout *layoutLocation = + new QGraphicsLinearLayout(Qt::Horizontal); + layoutLocation->setContentsMargins(0, 0, 0, 0); + widgetLocation->setLayout(layoutLocation); + + // Set the spacing between LineEdit and PushButton + qreal spacing = 0.0; + style()->parameter( + "hb-param-margin-gene-middle-horizontal", spacing); + layoutLocation->setSpacing(spacing); + + mLocationLineEdit = new HbLineEdit(this); mLocationLineEdit->setObjectName("locationLineEdit"); - mLocationLineEdit->setMinRows(1); mLocationLineEdit->setMaxRows(MaxRowsInTextItem); - mLocationPushButton = qobject_cast( - editorLocationDocLoader.findWidget( - CALEN_EDITOR_LOCATION_PUSHBUTTON)); + connect(mLocationLineEdit, SIGNAL(textChanged(const QString)), + this, SLOT(handleLocationTextChange(const QString))); + connect(mLocationLineEdit, SIGNAL(editingFinished()), + this, SLOT(handleEditingFinished())); + layoutLocation->addItem(mLocationLineEdit); + + mLocationPushButton = new HbPushButton(this); + + HbDeviceProfile deviceProfile; + // The layout guide specifies the spacing as 9.5 u + // and the height as 7.4 u + qreal width = deviceProfile.unitValue() * 9.5; + qreal height = deviceProfile.unitValue() * 7.4 ; + mLocationPushButton->setPreferredSize(width, height); + mLocationPushButton->setSizePolicy( + QSizePolicy::Fixed, QSizePolicy::Fixed); + mLocationPushButton->setIcon( HbIcon("qtg_mono_location")); mLocationPushButton->setObjectName("locationIcon"); - mLocationPushButton->setIcon( HbIcon("qtg_mono_location")); - connect(mLocationPushButton, SIGNAL(clicked()), this, SLOT(launchLocationPicker())); - connect(mLocationLineEdit, SIGNAL(textChanged(const QString)), - this, SLOT(handleLocationTextChange(const QString))); - - connect(mLocationLineEdit, SIGNAL(editingFinished()), - this, SLOT(handleEditingFinished())); - + layoutLocation->addItem(mLocationPushButton); OstTraceFunctionExit0( DUP2_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); return widgetLocation; } case RepeatUntilOffset: { - mRepeatUntilWidget = new HbPushButton(this); - mRepeatUntilWidget->setObjectName("repeatUntilItem"); - OstTraceFunctionExit0( DUP3_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); - return mRepeatUntilWidget; + setProperty("expandItem", false); + mRepeatUntilWidget = new HbPushButton(this); + mRepeatUntilWidget->setObjectName("repeatUntilItem"); + OstTraceFunctionExit0( DUP3_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); + return mRepeatUntilWidget; } case ReminderTimeOffset: { + setProperty("expandItem", false); mReminderTimeWidget = new HbPushButton(this); mReminderTimeWidget->setObjectName("remainderTimeItem"); OstTraceFunctionExit0( DUP4_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );