void QPropertyDelegate::paint(QPainter* pPainter, const QStyleOptionViewItem& pOption, const QModelIndex& pIndex) const { Q_ASSERT(pIndex.isValid()); // We don't need any specialized display for the "Property" column if( pIndex.column() == QPropertyModel::PROPERTY_COLUMN ) { QItemDelegate::paint(pPainter, pOption, pIndex); return; } const QPropertyModel* model = reinterpret_cast<const QPropertyModel*>(pIndex.model()); Property* baseProp = QPropertyModel::GetProperty(pIndex); QPropertyHelper* propHelper = QPropertyHelpersManager::GetHelper(baseProp->GetID()); /* if( !QPropertyModel::IsComponent(pIndex) ) printf("Painting %s\n", baseProp->GetName()); else printf("Painting %s.%s\n", baseProp->GetName(), baseProp->GetComponentName(QPropertyModel::GetComponentIndex(pIndex))); */ if( propHelper && model ) { if( propHelper->Paint(pPainter, pOption, model->GetEdited(), baseProp, QPropertyModel::GetComponentIndex(pIndex)) ) return; } QItemDelegate::paint(pPainter, pOption, pIndex); }
void QPropertyDelegate::setEditorData(QWidget* pEditor, const QModelIndex& pIndex) const { GD_ASSERT(pEditor == mActiveEditor); const QPropertyModel* model = reinterpret_cast<const QPropertyModel*>(pIndex.model()); Property* baseProp = QPropertyModel::GetProperty(pIndex); QPropertyHelper* propHelper = QPropertyHelpersManager::GetHelper(baseProp->GetID()); if( propHelper && model ) propHelper->SetEditorData(pEditor, model->GetEdited(), baseProp, QPropertyModel::GetComponentIndex(pIndex)); }
QWidget* QPropertyDelegate::createEditor(QWidget* pParent, const QStyleOptionViewItem& pOption, const QModelIndex& pIndex) const { Property* baseProp = QPropertyModel::GetProperty(pIndex); QPropertyDelegate* self = const_cast<QPropertyDelegate*>(this); QPropertyHelper* propHelper = QPropertyHelpersManager::GetHelper(baseProp->GetID()); if( propHelper ) self->mActiveEditor = propHelper->CreateEditor(self, pParent, pOption, baseProp, QPropertyModel::GetComponentIndex(pIndex)); if( self->mActiveEditor ) self->mActiveEditor->installEventFilter(self); return self->mActiveEditor; }
void QPropertyDelegate::setModelData(QWidget* pEditor, QAbstractItemModel* pModel, const QModelIndex& pIndex) const { GD_ASSERT(pEditor == mActiveEditor); if( !pIndex.isValid() ) return; QPropertyModel* model = reinterpret_cast<QPropertyModel*>(pModel); Property* baseProp = QPropertyModel::GetProperty(pIndex); QPropertyHelper* propHelper = QPropertyHelpersManager::GetHelper(baseProp->GetID()); if( propHelper && model ) propHelper->SetModelData(pEditor, model->GetEdited(), baseProp, QPropertyModel::GetComponentIndex(pIndex)); model->setData(pIndex, QVariant(), Qt::DisplayRole); }