// --------------------------------------------------------------------------- // PosSettingsPushButtonItem:::restore // --------------------------------------------------------------------------- // void PosSettingsPushButtonItem::restore() { HbDataFormViewItem::restore(); if (mWidget) { HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>( modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); if(itemType == PushButtonItem) { QModelIndex itemIndex = modelIndex(); HbDataFormModel *model = static_cast<HbDataFormModel*>(itemView()->model());; HbDataFormModelItem *modelItem = static_cast<HbDataFormModelItem*>( model->itemFromIndex(itemIndex)); const QMetaObject *metaObj = mWidget->metaObject(); int count = metaObj->propertyCount(); for (int i = 0; i < count; i++) { QMetaProperty metaProperty = metaObj->property(i); if (metaProperty.isValid() && metaProperty.isWritable()) { metaProperty.write(mWidget,modelItem->contentWidgetData(metaProperty.name())); } } } } }
HbWidget* CntEmailEditorViewItem::createCustomWidget() { mItem = new CntCommonDetailViewItem(this); mItem->editor()->setMaxLength( CNT_EMAIL_EDITOR_MAXLENGTH ); mItem->editor()->setInputMethodHints(Qt::ImhPreferLowercase); HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model()); CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) ); QContactDetail detail = item->detail(); mItem->editor()->setInputMethodHints( Qt::ImhEmailCharactersOnly ); constructSubTypeModel( detail.contexts() ); QContactEmailAddress address = detail; QString d = address.emailAddress(); mItem->editor()->setText( address.emailAddress() ); connect( mItem->comboBox(), SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)) ); connect( mItem->editor(), SIGNAL(textChanged(QString)),this, SLOT(textChanged(QString)) ); // Naming UI components for automation testability QString editorObjName = detail.definitionName() + " line edit %1"; mItem->editor()->setObjectName(editorObjName.arg(modelIndex().row())); QString comboBoxObjName = detail.definitionName() + " combo box %1"; mItem->comboBox()->setObjectName(comboBoxObjName.arg(modelIndex().row())); return mItem; }
void FmViewDetailsItem::updateChildItems() { if( !mLayout ) { init(); } QString string = modelIndex().data( Qt::DisplayRole ).toString(); mDetailsContentLabel->setPlainText( string ); string = modelIndex().data( Qt::UserRole ).toString(); mDetailsLabel->setPlainText( string ); }
void pCheckComboBox::showPopup() { if ( !model() ) { return; } Q_ASSERT( model()->inherits( "pGenericTableModel" ) ); const Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; for ( int i = 0; i < model()->rowCount( rootModelIndex() ); i++ ) { const QModelIndex index = modelIndex( i ); if ( isSeparator( index.row() ) ) { continue; } model()->setData( index, QSize( 0, 21 ), Qt::SizeHintRole ); if ( model()->inherits( "pGenericTableModel" ) ) { model()->setData( index, QVariant::fromValue( flags ), pGenericTableModel::ItemFlagsRole ); } if ( index.data( Qt::CheckStateRole ).isNull() ) { model()->setData( index, Qt::Unchecked, Qt::CheckStateRole ); } } pComboBox::showPopup(); }
bool HbDataGroup::setExpanded( bool expanded ) { Q_D(HbDataGroup); if(d->mSharedData->mItemView){ HbDataFormModelItem *modelItem = static_cast<HbDataFormModel*>( d->mSharedData->mItemView->model())->itemFromIndex(modelIndex()); HbDataFormModelItem::DataItemType contentWidgetType = static_cast<HbDataFormModelItem::DataItemType>( (d->mIndex.data(HbDataFormModelItem::ItemTypeRole)).toInt()); if( contentWidgetType == HbDataFormModelItem::GroupItem ) { d->setExpanded(expanded); } else if (contentWidgetType == HbDataFormModelItem::GroupPageItem) { //We need to change even the combobox state also so call pageChanged fuction if(modelItem) { int page = d->pageIndex(d->mIndex); if(page != -1) { pageChanged(page); } } } else if(contentWidgetType == HbDataFormModelItem::FormPageItem) { if(modelItem) { int formPageIndex = d->pageIndex(d->mIndex); if( formPageIndex!= -1) { HbDataFormPrivate::d_ptr( static_cast<HbDataForm*>(d->mSharedData->mItemView))->_q_page_changed(formPageIndex); } } } return true; } else { return false; } }
/*! \reimp To optimize loading css/xml definitions to take place only once, this function should be called only after other primitives (child items) has been created. */ void HbAbstractViewItem::updatePrimitives() { Q_D( HbAbstractViewItem); HbWidget::updatePrimitives(); // For debugging primitives #if 0 { QStringList listClasses; listClasses << "HbTreeViewItem"; const QMetaObject *meta = metaObject(); int count = listClasses.count(); for (int i=0; i< count; i++) { if ( meta->className() == listClasses.at(i)) { qDebug() << "HbAbstractViewItem::updatePrimitives(): widget, row, item count, check state" << listClasses.at(i) << modelIndex().row() << childItems().count() << d->mCheckState;; int count = childItems().count(); for (int i=0; i< count; i++) { if (childItems().at(i)) { HbTextItem *textItem = 0; if (childItems().at(i)->isWidget()) { textItem = qobject_cast<HbTextItem*>(static_cast<QGraphicsWidget*>(childItems().at(i))); } if (textItem) { qDebug() << " item #, item name, id: " << i << childItems().at(i)->data(0xfffe).toString() << textItem->text(); } else { qDebug() << " item #, item name: " << i << childItems().at(i)->data(0xfffe).toString(); } } } } } } #endif HbStyleOptionAbstractViewItem styleOption; initStyleOption(&styleOption); if (d->mBackgroundItem) { style()->updatePrimitive(d->mBackgroundItem, HbStyle::P_ItemViewItem_background, &styleOption); } if (d->mFrame) { style()->updatePrimitive(d->mFrame, HbStyle::P_ItemViewItem_frame, &styleOption); } if (d->mSelectionItem) { style()->updatePrimitive(d->mSelectionItem, HbStyle::P_ItemViewItem_selection, &styleOption); } if (d->mMultiSelectionTouchArea) { style()->updatePrimitive(d->mMultiSelectionTouchArea, HbStyle::P_ItemViewItem_touchmultiselection, &styleOption); } if (d->mFocusItem) { style()->updatePrimitive(d->mFocusItem, HbStyle::P_ItemViewItem_focus, &styleOption); } }
bool QxtScheduleInternalItem::setData(QVariant data, int role) { if (parentView() && parentView()->model()) { return parentView()->model()->setData(modelIndex(), data, role); } return false; }
void MessageModel::setTranslation(const iterator &it, const QString &translation) { int c = it.contextNo(); int m = it.messageNo(); QModelIndex idx = modelIndex(c, m, 2); MessageItem *msg = it.current(); msg->setTranslation(translation); emit dataChanged(idx, idx); }
void ZoomAction::emitZoomLevelChanged(int index) { m_currentComboBoxIndex = index; if (index == -1) return; QModelIndex modelIndex(m_comboBoxModel.data()->index(index, 0)); setZoomLevel(m_comboBoxModel.data()->data(modelIndex, Qt::UserRole).toDouble()); }
QModelIndex DiscoItemsModel::parent(const QModelIndex &AIndex) const { if (AIndex.isValid()) { DiscoItemIndex *index = itemIndex(AIndex); if (index && index->parent) return modelIndex(index->parent,AIndex.column()); } return QModelIndex(); }
// --------------------------------------------------------------------------- // PosSettingsPushButtonItem:::createCustomWidget // --------------------------------------------------------------------------- // HbWidget* PosSettingsPushButtonItem::createCustomWidget() { HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType> ( modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt() ); switch (itemType) { case PushButtonItem: { //custom button QString str = modelIndex().data(HbDataFormModelItem::PropertyRole).toString(); HbPushButton *button = new HbPushButton(str); mWidget = button; return mWidget; } default: return 0; } }
void DiscoItemsModel::appendTopLevelItem(const Jid &AItemJid, const QString &AItemNode) { if (findIndex(AItemJid,AItemNode,FRootIndex,false).isEmpty()) { DiscoItemIndex *index = new DiscoItemIndex; index->itemJid = AItemJid; index->itemNode = AItemNode; appendChildren(FRootIndex, QList<DiscoItemIndex*>()<<index); fetchMore(modelIndex(index,0)); } }
void pCheckComboBox::insertSeparator( int index ) { const int itemCount = count(); index = qBound( 0, index, itemCount ); if ( index >= maxCount() ) { return; } insertItem( index, QIcon(), QString::null ); pCheckComboBoxDelegate::setSeparator( model(), modelIndex( index ), true ); }
void EquipmentEditor::setEquipment( Equipment* e ) { if( e ) { obsEquip = e; // Make sure the combo box gets set to the right place. QModelIndex modelIndex(equipmentListModel->find(e)); QModelIndex viewIndex(equipmentSortProxyModel->mapFromSource(modelIndex)); if( viewIndex.isValid() ) equipmentComboBox->setCurrentIndex(viewIndex.row()); showChanges(); } }
/* ***************************************************************** * Name : createCustomWidget * Parameters : None * Return value: HbWidget * Description : creates a custom widget ***************************************************************** */ HbWidget *CpRemoteLockDataFormViewItem::createCustomWidget() { int type = modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt(); RDEBUG("type", type); if (type == CpCodeEditItem) { CpLockEdit *edit = new CpLockEdit("1234"); edit->setEchoMode(HbLineEdit::Password); edit->setReadOnly(true); return edit; } else { return 0; } }
/*! @beta Restores the data from the model and assign to the widget. The content widget property for restoring and saving the data need to be initialized when the data item is created. If model item type is custom, then application developer has to override this API in order to get notification when data is changed in model. \sa save */ void HbDataFormViewItem::restore() { Q_D( HbDataFormViewItem ); if( d->mType < HbDataFormModelItem::CustomItemBase ) { if( d->mContentWidget ) { QVariant newValue; QModelIndex itemIndex = modelIndex(); QString currentProperty; // fetch all properties set on this model item QHash<QString, QVariant> properties = d->mModelItem->contentWidgetData( ); QList <QString> propertyNames = properties.keys( ); int upperBound = 1; int lowerBound = 0; // get the latest modified property QString dirtyProperty = HbDataFormModelItemPrivate::d_ptr( d->mModelItem )->dirtyProperty( ); // First time when DataItem is created load all property, at runtime load only the modified // property. if( d->mSetAllProperty ) { upperBound = propertyNames.count() ; d->mSetAllProperty = false; } else { // Fetch only the last modified property lowerBound = propertyNames.indexOf(dirtyProperty); upperBound = lowerBound + 1; } if( lowerBound > -1 ) { for( ;lowerBound < upperBound ;lowerBound++) { newValue = properties.value(propertyNames.at(lowerBound)); currentProperty = propertyNames.at(lowerBound); if(newValue.isValid()) { if(!d->mContentWidget) { return; } d->mContentWidget->setProperty(currentProperty.toAscii().data(), newValue); } } } } } }
void HbDataGroup::pageChanged(int index) { Q_D(HbDataGroup); HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>( (d->mIndex.data(HbDataFormModelItem::ItemTypeRole)).toInt()); if(!itemView()) { return; } HbAbstractItemContainer *container = qobject_cast<HbAbstractItemContainer *>( static_cast<QGraphicsWidget *>(d->mSharedData->mItemView->contentWidget())); // Get Previous Active Group Page QModelIndex previousPageIndex; QModelIndex currentPageIndex; HbDataGroup* group = this; // this function can get called for both group and grouppage // active grouppage is always stored in group modelitem so get the next index and // activepage according to group int previous_page = d->activePage(); if(previous_page != -1) { previousPageIndex = d->pageModelIndex(previous_page); } currentPageIndex = d->pageModelIndex(index); if(itemType == HbDataFormModelItem::GroupPageItem) { // need to fetch group (parent) for getting previus page and active page group = static_cast<HbDataGroup*>(itemView()->itemByIndex(modelIndex().parent())); if(HbDataGroupPrivate::d_ptr(group)->mPageCombo) { if(HbDataGroupPrivate::d_ptr(group)->mPageCombo->currentIndex() != index) { // combobox has to be changed explicitly here since the call happened on GroupPage item QObject::disconnect(HbDataGroupPrivate::d_ptr(group)->mPageCombo,SIGNAL(currentIndexChanged(int)), group ,SLOT(pageChanged(int))); HbDataGroupPrivate::d_ptr(group)->mPageCombo->setCurrentIndex(index); QObject::connect(d->mPageCombo,SIGNAL(currentIndexChanged(int)), group ,SLOT(pageChanged(int))); } }
void CntEmailEditorViewItem::indexChanged( int aIndex ) { QString context = mItem->comboBox()->itemData( aIndex, DetailContext ).toString(); // check that if current QContactDetail contains the changed subtype HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model()); CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) ); QStringList contextList; if ( !context.isEmpty() ) contextList << context; QContactEmailAddress address = item->detail(); address.setContexts( contextList ); item->setDetail( address ); }
void pCheckComboBox::setSeparator( int index, bool set ) { mDelegate->setSeparator( model(), modelIndex( index ), set ); }
bool pCheckComboBox::isSeparator( int index ) { return mDelegate->isSeparator( modelIndex( index ) ); }
QModelIndex DiscoItemsModel::index(int ARow, int AColumn, const QModelIndex &AParent) const { return modelIndex(itemIndex(AParent)->childs.value(ARow),AColumn); }
/*! From HbAbstractViewItem. \sa HbAbstractViewItem, HbGridViewItem */ void CalenGridItemPrototype::updateChildItems() { OstTraceFunctionEntry0( CALENGRIDITEMPROTOTYPE_UPDATECHILDITEMS_ENTRY ); // Here update content of each item. QVariant monthDayRole; bool monthFocusRole; bool underlineEnabled = false; bool monthEventRole; bool monthTextColorRole; QVariant itemData = modelIndex().data(Qt::UserRole + 1); if (itemData.isValid()) { if (itemData.canConvert<QVariantList>()) { // Get the item list QVariantList itemList = itemData.toList(); // Get the day text monthDayRole = itemList.at(CalendarNamespace::CalendarMonthDayRole); if (monthDayRole.canConvert<QString>()) { mMonthDayInfoItem->setText(monthDayRole.toString()); } // Get the focus data monthFocusRole = itemList.at(CalendarNamespace::CalendarMonthFocusRole).value<bool>(); if (monthFocusRole) { mFocusIndicatorItem->frameDrawer().setFrameGraphicsName(focusIconName); } else { mFocusIndicatorItem->frameDrawer().setFrameGraphicsName(QString("")); } // Get the today indicator role underlineEnabled = itemList.at( CalendarNamespace::CalendarMonthUnderlineRole). value<bool>(); if(underlineEnabled) { mTodayIndicatorItem->show(); } else { mTodayIndicatorItem->hide(); } // Get the event indicator data monthEventRole = itemList.at(CalendarNamespace::CalendarMonthEventRole).value<bool>(); if (monthEventRole) { // Set the event indicator //QString iconName(focusIconName); mEventIndicatorItem->setIconName(eventIndname); } else { mEventIndicatorItem->setIconName(QString("")); } // Get the text color monthTextColorRole = itemList.at(CalendarNamespace::CalendarMonthTextColorRole).value<bool>(); if (monthTextColorRole) { if (monthFocusRole) { // Set the Highlighted text color mMonthDayInfoItem->setTextColor(mCurrentDateColor); } else { // Set the active text color mMonthDayInfoItem->setTextColor(mActiveTextColor); } } else { // Set the inactive text color mMonthDayInfoItem->setTextColor(mInActiveTextColor); } } } // base class implementation HbGridViewItem::updateChildItems(); OstTraceFunctionExit0( CALENGRIDITEMPROTOTYPE_UPDATECHILDITEMS_EXIT ); }
/*! Creates the custom widget. */ HbWidget* CalenEditorCustomItem::createCustomWidget() { OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_ENTRY ); HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType> (modelIndex() .data( HbDataFormModelItem::ItemTypeRole).toInt()); switch (itemType) { case CustomWidgetFrom: { // 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())); layoutTop->addItem(mPushButtonTime); mPushButtonDate = new HbPushButton(); mPushButtonDate->setPreferredWidth(buttonWidth); mPushButtonDate->setObjectName("startDate"); connect(mPushButtonDate, SIGNAL(clicked()), this, SLOT(handleDate())); layoutTop->addItem(mPushButtonDate); OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); return widgetTop; } case CustomWidgetTo: { // 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); // 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; } case CustomWidgetLocation: { 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->setMaxRows(MaxRowsInTextItem); 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"); connect(mLocationPushButton, SIGNAL(clicked()), this, SLOT(launchLocationPicker())); layoutLocation->addItem(mLocationPushButton); OstTraceFunctionExit0( DUP2_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); return widgetLocation; } case RepeatUntilOffset: { 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 ); return mReminderTimeWidget; } default: return 0; } }
QRect QITreeViewItem::rect() const { /* Redirect call to parent-tree: */ return parentTree() ? parentTree()->visualRect(modelIndex()) : QRect(); }
QVariant QxtScheduleInternalItem::data(int role) const { if (modelIndex().isValid()) return modelIndex().data(role); return QVariant(); }
void CntEmailEditorViewItem::textChanged( QString aText ) { HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model()); CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) ); QContactEmailAddress address = item->detail(); address.setEmailAddress( aText ); item->setDetail( address ); }