本文整理汇总了C++中PropertyItem类的典型用法代码示例。如果您正苦于以下问题:C++ PropertyItem类的具体用法?C++ PropertyItem怎么用?C++ PropertyItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PropertyItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PropertyItem
PropertyItem* PropertyItemFromQObject::buildPropertyItem( const QObject *object, QMetaProperty &qmprop, PropertyItem *parent ) {
PropertyItem * prop = 0;
if(!qmprop.isWritable()&&_skipRO)
return prop;
if ( _itemFactory && qmprop.read( object ).isValid()) {
QString key = qmprop.read( object ).typeName();
PropertyItemProvider *itemProvider = _itemFactory->get
<PropertyItemProvider>( key );
if ( itemProvider == 0 ) //on tente de recuperer le provider par defaut
itemProvider = _itemFactory->get
<PropertyItemProvider>( PropertyItemDefaultFactory::K_DEFAULT_KEY );
if ( itemProvider != 0 )
prop = itemProvider->fromQVariant( qmprop.name(), qmprop.read( object ), parent );
}
//si 0 c'est que la creation depuis la factory a echoue
if ( prop == 0 ) {
//on cree par defaut
prop = new PropertyItem( qmprop.name(), parent );
prop->setData( qmprop.read( object ) );
}
prop->setValueHolder( new PropertyItemQPropertyValueHolder(qmprop,const_cast<QObject*>(object)));
return prop;
}
示例2: updatetEditorMode
void PropertyEditor::updatetEditorMode(const App::Property& prop)
{
// check if the parent object is selected
std::string editor = prop.getEditorName();
if (editor.empty())
return;
bool hidden = prop.testStatus(App::Property::Hidden);
bool readOnly = prop.testStatus(App::Property::ReadOnly);
int column = 1;
int numRows = propertyModel->rowCount();
for (int i=0; i<numRows; i++) {
QModelIndex item = propertyModel->index(i, column);
PropertyItem* propItem = static_cast<PropertyItem*>(item.internalPointer());
if (propItem && propItem->hasProperty(&prop)) {
setRowHidden (i, QModelIndex(), hidden);
propItem->updateData();
if (item.isValid()) {
updateItemEditor(!readOnly, column, item);
dataChanged(item, item);
}
break;
}
}
}
示例3: setModelData
void PropertyItemDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
if (!index.isValid())
return;
PropertyItem *childItem = static_cast<PropertyItem*>(index.internalPointer());
QVariant data = childItem->editorData(editor);
model->setData(index, data, Qt::EditRole);
}
示例4: QVariant
QVariant PropertyModel::data ( const QModelIndex & index, int role ) const
{
if (!index.isValid())
return QVariant();
PropertyItem *item = static_cast<PropertyItem*>(index.internalPointer());
return item->data(index.column(), role);
}
示例5: retrieveItem
int PropertyModel::rowCount(const QModelIndex & parentIndex) const
{
if (parentIndex.column() > 0)
return 0;
PropertyItem * item = parentIndex.isValid() ? retrieveItem(parentIndex) : m_root;
return item->childCount();
}
示例6: QModelIndex
QModelIndex PropertyModel::index(int row, int column, const QModelIndex & parentIndex) const
{
if (!hasIndex(row, column, parentIndex))
return QModelIndex();
PropertyItem * item = parentIndex.isValid() ? retrieveItem(parentIndex) : m_root;
return createIndex(item->at(row), column);
}
示例7: toItem
PropertyRenderer *PropertyDelegate::getRendererFor( const QModelIndex & index ) const {
if ( _factory == 0 )
return 0;
PropertyItem * data = toItem( index );
if ( data == 0 )
return 0;
QString renderer = ( index.column() == 0 ) ? data->nameRenderer() : data->valueRenderer();
return ( renderer == "" ) ? 0 : _factory->get<PropertyRenderer>( renderer );
}
示例8: modelIndexToData
void PropertyRendererPixmap::paintProperty ( QPainter * painter, const QStyleOptionViewItem &option, const QModelIndex &index ) {
static const int i = 16;
PropertyItem *data = modelIndexToData( index );
if ( data == 0 )
return ;
QRect rect = option.rect;
QRect pixRec = QRect( rect.left() + i / 2, rect.top() + ( rect.height() - i ) / 2, i, i );
QPixmap pix = getPixmapFromQVariant( data->data() );
painter->drawPixmap( pixRec, pix );
}
示例9: PropertyTree
ScreenProperties::ScreenProperties(QWidget *parent) :
PropertyTree(parent)
{
PropertyItem *section = insertSection(tr("Screen"));
width = new PropertyItem(0);
height = new PropertyItem(0);
section->appendRow(tr("width"), width);
section->appendRow(tr("height"), height);
}
示例10: toggleOpen
void CXmlPropertyList::toggleOpen( QListViewItem *i )
{
if ( !i )
return;
PropertyItem *pi = (PropertyItem*)i;
if ( pi->hasSubItems() ) {
pi->setOpen( !pi->isOpen() );
} else {
pi->toggle();
}
}
示例11: setEditorData
void PropertyItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
if (!index.isValid())
return;
QVariant data = index.data(Qt::EditRole);
PropertyItem *childItem = static_cast<PropertyItem*>(index.internalPointer());
editor->blockSignals(true);
childItem->setEditorData(editor, data);
editor->blockSignals(false);
return;
}
示例12: itemPressed
void CXmlPropertyList::itemPressed( QListViewItem *i, const QPoint &p, int c )
{
if ( !i )
return;
PropertyItem *pi = (PropertyItem*)i;
if ( !pi->hasSubItems() )
return;
if ( c == 0 && viewport()->mapFromGlobal( p ).x() < 20 )
toggleOpen( i );
}
示例13: rowCount
int PropertyModel::rowCount ( const QModelIndex & parent ) const
{
PropertyItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<PropertyItem*>(parent.internalPointer());
return parentItem->childCount();
}
示例14: QModelIndex
QModelIndex PropertyModel::parent ( const QModelIndex & index ) const
{
if (!index.isValid())
return QModelIndex();
PropertyItem *childItem = static_cast<PropertyItem*>(index.internalPointer());
PropertyItem *parentItem = childItem->parent();
if (parentItem == rootItem)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
}
示例15: paint
void PropertyItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const
{
QStyleOptionViewItem option = opt;
PropertyItem *property = static_cast<PropertyItem*>(index.internalPointer());
if (property && property->isSeparator()) {
QColor color = option.palette.color(QPalette::BrightText);
QObject* par = parent();
if (par) {
QVariant value = par->property("groupTextColor");
if (value.canConvert<QColor>())
color = value.value<QColor>();
}
option.palette.setColor(QPalette::Text, color);
option.font.setBold(true);
option.state &= ~QStyle::State_Selected;
}
if (index.column() == 1) {
option.state &= ~QStyle::State_Selected;
}
option.state &= ~QStyle::State_HasFocus;
if (property && property->isSeparator()) {
QBrush brush = option.palette.dark();
QObject* par = parent();
if (par) {
QVariant value = par->property("groupBackground");
if (value.canConvert<QBrush>())
brush = value.value<QBrush>();
}
painter->fillRect(option.rect, brush);
}
QPen savedPen = painter->pen();
QItemDelegate::paint(painter, option, index);
QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt, qobject_cast<QWidget*>(parent())));
painter->setPen(QPen(color));
if (index.column() == 1 || !(property && property->isSeparator())) {
int right = (option.direction == Qt::LeftToRight) ? option.rect.right() : option.rect.left();
painter->drawLine(right, option.rect.y(), right, option.rect.bottom());
}
painter->drawLine(option.rect.x(), option.rect.bottom(),
option.rect.right(), option.rect.bottom());
painter->setPen(savedPen);
}