bool UnitWidget::add() { if (AbstractModifyWidget::add(DBUNITXML::UNIT)) { QModelIndex index = itemView()->currentIndex(); proxyModel()->setData(index.sibling( index.row(), model()->columnDisplayedAttr( DBUNITXML::UNIT, DBUNITXML::COEFF) ), 1); proxyModel()->setData(index.sibling( index.row(), model()->columnDisplayedAttr( DBUNITXML::UNIT, DBUNITXML::DELTA) ), 0); proxyModel()->setData(index.sibling( index.row(), model()->columnDisplayedAttr( DBUNITXML::UNIT, DBUNITXML::CODE) ), 0); return true; } return false; }
// --------------------------------------------------------------------------- // 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 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 ); }
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))); } }
QSize ServiceItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(index); const QStyle *style = itemView()->style(); const int buttonHeight = style->pixelMetric(QStyle::PM_ButtonMargin) * 2 + style->pixelMetric(QStyle::PM_ButtonIconSize); const int fontHeight = option.fontMetrics.height(); return QSize(100, qMax(buttonHeight, fontHeight)); }
LovValueWidget::LovValueWidget(QWidget *parent) : AbstractModifyWidget(parent) { setupUi(this); connect(toolButtonAddLovValue, &QToolButton::clicked, this, &LovValueWidget::add); connect(toolButtonDeleteLovValue, &QToolButton::clicked, this, &LovValueWidget::remove); AbstractModifyWidget::setItemView(tableViewLovValue); itemView()->setItemDelegate(new LovDelegate()); }
UnitWidget::UnitWidget(QWidget *parent) : AbstractModifyWidget(parent) { setupUi(this); connect(toolButtonAddUnit, &QToolButton::clicked, this, &UnitWidget::add); connect(toolButtonDeleteUnit, &QToolButton::clicked, this, &UnitWidget::remove); AbstractModifyWidget::setItemView(tableViewUnit); itemView()->setItemDelegate(new UnitDelegate()); }
void ServiceItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { Q_UNUSED(index); painter->save(); itemView()->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter); if (option.state & QStyle::State_Selected) { painter->setPen(option.palette.highlightedText().color()); } painter->restore(); }
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 ); }
/*! \reimp Updates child graphics items to represent current state and content stored in model. In case when HbDataFormViewItem represents data item and DataItemType is set to custom item, then createCustomWidget is called. User can override createCustomWidget and can pass his own custom widget. \sa createCustomWidget */ void HbDataFormViewItem::updateChildItems() { Q_D( HbDataFormViewItem ); d->init(); //this will create the visualization for all standard data items d->createContentWidget( ); //set the label in data iem QString itemLabel = d->mIndex.data( HbDataFormModelItem::LabelRole ).toString( ); d->setLabel( itemLabel ); // set the icon in data item QString icon = d->mIndex.data( Qt::DecorationRole ).toString( ); d->setIcon( icon ); // set the description of data item QString itemDescription = d->mIndex.data( HbDataFormModelItem::DescriptionRole ).toString(); d->setDescription( itemDescription ); //update visualization based on whether item is enabled or disabled HbDataFormModel* data_model = static_cast<HbDataFormModel*>(itemView()->model()); HbDataFormModelItem *model_item = static_cast<HbDataFormModelItem*>(data_model->itemFromIndex(d->mIndex)); d->setEnabled(model_item->isEnabled()); #ifdef HB_EFFECTS //HbEffectInternal::add( HB_DATAFORMVIEWITEM_TYPE,"dataform_expand", "expanded" ); //HbEffect::start( settingItem, HB_DATAFORMVIEWITEM_TYPE, "expanded" ); #endif restore( ); // Establish Signal Connections set in HbDataFormModel to th contentWidget of this item HbDataFormPrivate::d_ptr( static_cast<HbDataForm*>(d->mSharedData->mItemView))->makeConnection( d->mIndex.operator const QModelIndex & (),d->mContentWidget); //update only the background primitive HbStyleOptionDataFormViewItem options; initStyleOption(&options); if( d->mBackgroundItem ) { style()->updatePrimitive( d->mBackgroundItem, HbStyle::P_DataItem_background, &options ); } }
NumeratorRangeWidget::NumeratorRangeWidget(QWidget *parent) : AbstractModifyWidget(parent) { setupUi(this); connect(addLovToolButton, &QToolButton::clicked, this, &NumeratorRangeWidget::addLov); connect(addRegExToolButton, &QToolButton::clicked, this, &NumeratorRangeWidget::addRegEx); connect(deleteToolButton, &QToolButton::clicked, this, &NumeratorRangeWidget::remove); connect(upRangeToolButton, &QToolButton::clicked, this, &NumeratorRangeWidget::up); connect(downRangeToolButton, &QToolButton::clicked, this, &NumeratorRangeWidget::down); AbstractModifyWidget::setItemView(numeratorRangeTableView); itemView()->setItemDelegate(new NumeratorRangeDelegate()); }
void UnitWidget::setModel(TreeXmlHashModel *model) { AbstractModifyWidget::setModel(model); proxyModel()->setHeaderData(0, Qt::Horizontal, tr("Наименование")); proxyModel()->setHeaderData(1, Qt::Horizontal, tr("Код ОКЕИ")); proxyModel()->setHeaderData(2, Qt::Horizontal, tr("Коэффициент")); proxyModel()->setHeaderData(3, Qt::Horizontal, tr("Разница")); proxyModel()->setHeaderData(4, Qt::Horizontal, tr("Обозначение")); proxyModel()->setHeaderData(5, Qt::Horizontal, tr("Символы")); proxyModel()->setHeaderData(6, Qt::Horizontal, tr("Обозначение (межд.)")); proxyModel()->setHeaderData(7, Qt::Horizontal, tr("Символы (межд.)")); proxyModel()->setHeaderData(8, Qt::Horizontal, tr("Величина")); proxyModel()->setHeaderData(9, Qt::Horizontal, tr("Идентификатор")); itemView()->setModel(proxyModel()); for (qint32 column = 8; column < 18; ++column) tableViewUnit->setColumnHidden(column,true); tableViewUnit->horizontalHeader()->setDefaultSectionSize(75); }
int MainUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: updatePointView((*reinterpret_cast< hash_map<int,Entity*>*(*)>(_a[1]))); break; case 1: updateNodeInfo((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 2: newProject(); break; case 3: quit(); break; case 4: showAllObjects(); break; case 5: saveCurrentScreen(); break; case 6: itemView(); break; case 7: editorView(); break; case 8: filterPtsByOBAFilter(); break; case 9: classifyObjs(); break; case 10: resetEntitysType(); break; case 11: extractBuildingManual(); break; case 12: exportBuilding(); break; case 13: autoRun(); break; case 14: datasetInfo(); break; case 15: importDTM(); break; case 16: importPoint(); break; case 17: importRectangle(); break; case 18: importTIN(); break; case 19: text2las(); break; case 20: las2text(); break; case 21: about(); break; case 22: showMousePos((*reinterpret_cast< const int(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break; case 23: identifyObject((*reinterpret_cast< const int(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break; case 24: cancelBuilding((*reinterpret_cast< const int(*)>(_a[1]))); break; case 25: useEntityParam((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break; default: ; } _id -= 26; } return _id; }
void HbTumbleViewItem::gestureEvent(QGestureEvent *event) { HbTapGesture *gesture = static_cast<HbTapGesture *>(event->gesture(Qt::TapGesture)); if (gesture) { Q_D(HbAbstractViewItem); if(itemView()->isScrolling()){ event->ignore(); event->ignore(Qt::TapGesture); return; } if(gesture->state() == Qt::GestureCanceled){ d->setPressed(false, false); event->accept(); scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant()); return; } d->tapTriggered(event); } else { HbWidget::gestureEvent(event); } }
void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const { // draws: // AccountName // Checkbox | Icon | | ConnectionIcon | ConnectionState // errorMessage if (!index.isValid()) { return; } Q_ASSERT(widgets.size() == 6); // Get the widgets QCheckBox* checkbox = qobject_cast<QCheckBox*>(widgets.at(0)); ChangeIconButton* changeIconButton = qobject_cast<ChangeIconButton*>(widgets.at(1)); QLabel *statusTextLabel = qobject_cast<QLabel*>(widgets.at(2)); QLabel *statusIconLabel = qobject_cast<QLabel*>(widgets.at(3)); EditDisplayNameButton *displayNameButton = qobject_cast<EditDisplayNameButton*>(widgets.at(4)); QLabel *connectionErrorLabel = qobject_cast<QLabel*>(widgets.at(5)); Q_ASSERT(checkbox); Q_ASSERT(changeIconButton); Q_ASSERT(statusTextLabel); Q_ASSERT(statusIconLabel); Q_ASSERT(displayNameButton); Q_ASSERT(connectionErrorLabel); bool isSelected(itemView()->selectionModel()->isSelected(index) && itemView()->hasFocus()); bool isEnabled(index.data(KTp::AccountsListModel::EnabledRole).toBool()); KIcon accountIcon(index.data(Qt::DecorationRole).value<QIcon>()); KIcon statusIcon(index.data(KTp::AccountsListModel::ConnectionStateIconRole).value<QIcon>()); QString statusText(index.data(KTp::AccountsListModel::ConnectionStateDisplayRole).toString()); QString displayName(index.data(Qt::DisplayRole).toString()); QString connectionError(index.data(KTp::AccountsListModel::ConnectionErrorMessageDisplayRole).toString()); Tp::AccountPtr account(index.data(KTp::AccountsListModel::AccountRole).value<Tp::AccountPtr>()); if (!account->isEnabled()) { connectionError = i18n("Click checkbox to enable"); } QRect outerRect(0, 0, option.rect.width(), option.rect.height()); QRect contentRect = outerRect.adjusted(m_hpadding,m_vpadding,-m_hpadding,-m_vpadding); //add some padding // checkbox if (isEnabled) { checkbox->setChecked(true);; checkbox->setToolTip(i18n("Disable account")); } else { checkbox->setChecked(false); checkbox->setToolTip(i18n("Enable account")); } int checkboxLeftMargin = contentRect.left(); int checkboxTopMargin = (outerRect.height() - checkbox->height()) / 2; checkbox->move(checkboxLeftMargin, checkboxTopMargin); // changeIconButton changeIconButton->setIcon(accountIcon); changeIconButton->setAccount(account); // At the moment (KDE 4.8.1) decorationSize is not passed from KWidgetItemDelegate // through the QStyleOptionViewItem, therefore we leave default size unless // the user has a more recent version. if (option.decorationSize.width() > -1) { changeIconButton->setButtonIconSize(option.decorationSize.width()); } int changeIconButtonLeftMargin = checkboxLeftMargin + checkbox->width(); int changeIconButtonTopMargin = (outerRect.height() - changeIconButton->height()) / 2; changeIconButton->move(changeIconButtonLeftMargin, changeIconButtonTopMargin); // statusTextLabel QFont statusTextFont = option.font; QPalette statusTextLabelPalette = option.palette; if (isEnabled) { statusTextLabel->setEnabled(true); statusTextFont.setItalic(false); } else { statusTextLabel->setDisabled(true); statusTextFont.setItalic(true); } if (isSelected) { statusTextLabelPalette.setColor(QPalette::Text, statusTextLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } statusTextLabel->setPalette(statusTextLabelPalette); statusTextLabel->setFont(statusTextFont); statusTextLabel->setText(statusText); statusTextLabel->setFixedSize(statusTextLabel->fontMetrics().boundingRect(statusText).width(), statusTextLabel->height()); int statusTextLabelLeftMargin = contentRect.right() - statusTextLabel->width(); int statusTextLabelTopMargin = (outerRect.height() - statusTextLabel->height()) / 2; statusTextLabel->move(statusTextLabelLeftMargin, statusTextLabelTopMargin); // statusIconLabel statusIconLabel->setPixmap(statusIcon.pixmap(KIconLoader::SizeSmall)); statusIconLabel->setFixedSize(statusIconLabel->minimumSizeHint()); int statusIconLabelLeftMargin = contentRect.right() - statusTextLabel->width() - statusIconLabel->width() - 6; int statusIconLabelTopMargin = (outerRect.height() - statusIconLabel->height()) / 2; statusIconLabel->move(statusIconLabelLeftMargin, statusIconLabelTopMargin); QRect innerRect = contentRect.adjusted(changeIconButton->geometry().right() - contentRect.left(), 0, -statusTextLabel->width() - statusIconLabel->width() - 6, 0); // rect containing account name and error message // displayNameButton QFont displayNameButtonFont = option.font; QPalette displayNameButtonPalette = option.palette; if (isEnabled) { displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::Text)); displayNameButtonFont.setBold(true); } else { displayNameButtonFont.setItalic(true); // NOTE: Flat QPushButton use WindowText instead of ButtonText for button text color displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::HighlightedText)); } displayNameButton->setFont(displayNameButtonFont); displayNameButton->setPalette(displayNameButtonPalette); QString displayNameButtonText = displayNameButton->fontMetrics().elidedText(displayName, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); displayNameButton->setText(displayNameButtonText); displayNameButton->setFixedSize(displayNameButton->fontMetrics().boundingRect(displayNameButtonText).width() + (m_hpadding*2), displayNameButton->minimumSizeHint().height()); displayNameButton->setAccount(account); int displayNameButtonLeftMargin = innerRect.left(); int displayNameButtonTopMargin = innerRect.top(); displayNameButton->move(displayNameButtonLeftMargin, displayNameButtonTopMargin); // connectionErrorLabel QFont connectionErrorLabelFont = option.font; QPalette connectionErrorLabelPalette = option.palette; if (isEnabled) { connectionErrorLabelPalette.setColor(QPalette::WindowText, connectionErrorLabelPalette.color(QPalette::Active, QPalette::Text)); } else { connectionErrorLabelFont.setItalic(true); connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } connectionErrorLabel->setFont(connectionErrorLabelFont); connectionErrorLabel->setPalette(connectionErrorLabelPalette); QString connectionErrorLabelText = connectionErrorLabel->fontMetrics().elidedText(connectionError, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); connectionErrorLabel->setText(connectionErrorLabelText); connectionErrorLabel->setFixedSize(connectionErrorLabel->fontMetrics().boundingRect(connectionErrorLabelText).width(), displayNameButton->height()); int connectionErrorLabelLeftMargin = innerRect.left() + m_hpadding; int connectionErrorLabelTopMargin = contentRect.bottom() - displayNameButton->height(); connectionErrorLabel->move(connectionErrorLabelLeftMargin, connectionErrorLabelTopMargin); }
LovValueWidget::~LovValueWidget() { delete itemView()->itemDelegate(); }
UnitWidget::~UnitWidget() { delete itemView()->itemDelegate(); }
bool WindowManager::canDrag(QWidget *widget, QWidget *child, const QPoint &position) { // retrieve child at given position and check cursor again if (child && Qt::ArrowCursor!=child->cursor().shape()) { return false; } /* check against children from which drag should never be enabled, even if mousePress/Move has been passed to the parent */ if (child && (qobject_cast<QComboBox*>(child) || qobject_cast<QProgressBar*>(child))) { return false; } // tool buttons if (QToolButton *toolButton = qobject_cast<QToolButton*>(widget)) { if (dragMode() < WM_DRAG_ALL && !isToolBar(widget->parentWidget())) { return false; } return toolButton->autoRaise() && !toolButton->isEnabled(); } // check menubar if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(widget)) { // check if there is an active action if (menuBar->activeAction() && menuBar->activeAction()->isEnabled()) { return false; } // check if action at position exists and is enabled if (QAction *action = menuBar->actionAt(position)) { if (action->isSeparator()) { return true; } if (action->isEnabled()) { return false; } } // return true in all other cases return true; } bool toolbar=isToolBar(widget); if (dragMode() < WM_DRAG_MENU_AND_TOOLBAR && toolbar) { return false; } /* in MINIMAL mode, anything that has not been already accepted and does not come from a toolbar is rejected */ if (dragMode() < WM_DRAG_ALL) { return toolbar; } /* following checks are relevant only for WD_FULL mode */ // tabbar. Make sure no tab is under the cursor if (QTabBar *tabBar = qobject_cast<QTabBar*>(widget)) { return -1==tabBar->tabAt(position); } /* check groupboxes prevent drag if unchecking grouboxes */ if (QGroupBox *groupBox = qobject_cast<QGroupBox*>(widget)) { // non checkable group boxes are always ok if (!groupBox->isCheckable()) { return true; } // gather options to retrieve checkbox subcontrol rect QStyleOptionGroupBox opt; opt.initFrom(groupBox); if (groupBox->isFlat()) { opt.features |= QStyleOptionFrameV2::Flat; } opt.lineWidth = 1; opt.midLineWidth = 0; opt.text = groupBox->title(); opt.textAlignment = groupBox->alignment(); opt.subControls = (QStyle::SC_GroupBoxFrame | QStyle::SC_GroupBoxCheckBox); if (!groupBox->title().isEmpty()) { opt.subControls |= QStyle::SC_GroupBoxLabel; } opt.state |= (groupBox->isChecked() ? QStyle::State_On : QStyle::State_Off); // check against groupbox checkbox if (groupBox->style()->subControlRect(QStyle::CC_GroupBox, &opt, QStyle::SC_GroupBoxCheckBox, groupBox).contains(position)) { return false; } // check against groupbox label if (!groupBox->title().isEmpty() && groupBox->style()->subControlRect(QStyle::CC_GroupBox, &opt, QStyle::SC_GroupBoxLabel, groupBox).contains(position)) { return false; } return true; } // labels if (QLabel *label = qobject_cast<QLabel*>(widget)) { if (label->textInteractionFlags().testFlag(Qt::TextSelectableByMouse)) { return false; } } // abstract item views QAbstractItemView *itemView(NULL); if ((itemView = qobject_cast<QListView*>(widget->parentWidget())) || (itemView = qobject_cast<QTreeView*>(widget->parentWidget()))) { if (widget == itemView->viewport()) { // QListView if (QFrame::NoFrame!=itemView->frameShape()) { return false; } else if (QAbstractItemView::NoSelection!=itemView->selectionMode() && QAbstractItemView::SingleSelection!=itemView->selectionMode() && itemView->model() && itemView->model()->rowCount()) { return false; } else if (itemView->model() && itemView->indexAt(position).isValid()) { return false; } } } else if ((itemView = qobject_cast<QAbstractItemView*>(widget->parentWidget()))) { if (widget == itemView->viewport()) { // QAbstractItemView if (QFrame::NoFrame!=itemView->frameShape()) { return false; } else if (itemView->indexAt(position).isValid()) { return false; } } } return true; }
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const { //paint background for selected or hovered item QStyleOptionViewItemV4 opt = option; itemView()->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, 0); }
NumeratorRangeWidget::~NumeratorRangeWidget() { delete itemView()->itemDelegate(); }
void PluginListWidgetItemDelegate::slotAboutClicked() { auto const index = focusedIndex(); auto const model = index.model(); auto info = QString{}; info += tr("Plugin name: %1").arg(model->data(index, PluginModel::NameRole).toString()) + "\n"; auto pluginMetadata = model->data(index, PluginModel::MetadataRole).value<PluginMetadata>(); info += tr("Author: %1").arg(pluginMetadata.author()) + "\n"; info += tr("Version: %1").arg(pluginMetadata.version()) + "\n"; info += tr("Description: %1").arg(pluginMetadata.description()) + "\n"; info += tr("Dependencies: %1").arg(pluginMetadata.dependencies().join(", ")) + "\n"; info += tr("Provides: %1").arg(pluginMetadata.provides()); MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-information")), tr("Plugin information"), info, QMessageBox::Ok, itemView()); }