当前位置: 首页>>代码示例>>C++>>正文


C++ PropertyItem类代码示例

本文整理汇总了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;

  }
开发者ID:MassMessage,项目名称:qpropertygrid,代码行数:29,代码来源:PropertyItemFromQObject.cpp

示例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;
        }
    }
}
开发者ID:ctbenergy,项目名称:FreeCAD,代码行数:27,代码来源:PropertyEditor.cpp

示例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);
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:8,代码来源:PropertyItemDelegate.cpp

示例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);
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:8,代码来源:PropertyModel.cpp

示例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();
}
开发者ID:dgimb89,项目名称:libzeug,代码行数:9,代码来源:PropertyModel.cpp

示例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);
}
开发者ID:dgimb89,项目名称:libzeug,代码行数:9,代码来源:PropertyModel.cpp

示例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 );
  }
开发者ID:MassMessage,项目名称:qpropertygrid,代码行数:9,代码来源:PropertyDelegate.cpp

示例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 );
  }
开发者ID:MassMessage,项目名称:qpropertygrid,代码行数:10,代码来源:TypePixmap.cpp

示例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);
}
开发者ID:guillaumecl,项目名称:yggdrasil,代码行数:10,代码来源:screenproperties.cpp

示例10: toggleOpen

void CXmlPropertyList::toggleOpen( QListViewItem *i )
{
    if ( !i )
	return;
    PropertyItem *pi = (PropertyItem*)i;
    if ( pi->hasSubItems() ) {
	pi->setOpen( !pi->isOpen() );
    } else {
	pi->toggle();
    }
}
开发者ID:nanzhang790,项目名称:View3dn,代码行数:11,代码来源:xmlpropertylist.cpp

示例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;
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:11,代码来源:PropertyItemDelegate.cpp

示例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 );
}
开发者ID:nanzhang790,项目名称:View3dn,代码行数:11,代码来源:xmlpropertylist.cpp

示例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();
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:11,代码来源:PropertyModel.cpp

示例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);
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:13,代码来源:PropertyModel.cpp

示例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);
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:50,代码来源:PropertyItemDelegate.cpp


注:本文中的PropertyItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。