本文整理汇总了C++中QtPropertyData类的典型用法代码示例。如果您正苦于以下问题:C++ QtPropertyData类的具体用法?C++ QtPropertyData怎么用?C++ QtPropertyData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QtPropertyData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: itemFromIndex
QVariant QtPropertyModel::data(const QModelIndex & index, int role /* = Qt::DisplayRole */) const
{
QVariant ret;
QtPropertyData *data = itemFromIndex(index);
if(NULL != data)
{
if(index.column() == 0)
{
switch(role)
{
case Qt::DisplayRole:
case Qt::ToolTipRole:
ret = data->GetName();
break;
case Qt::FontRole:
case Qt::BackgroundRole:
case Qt::ForegroundRole:
ret = data->data(role);
break;
default:
break;
}
}
else if(index.column() == 1)
{
ret = data->data(role);
}
}
return ret;
}
示例2: itemFromIndexInternal
void QtPropertyModel::MergeProperty(QtPropertyData* data, QModelIndex const& parent)
{
if(NULL != data)
{
QtPropertyData *parentData = itemFromIndexInternal(parent);
if(NULL != parentData)
{
parentData->MergeChild(data);
}
}
}
示例3: QtPropertyDataDavaKeyedArcive
void QtPropertyDataIntrospection::AddMember(const DAVA::IntrospectionMember *member, int hasAnyFlags, int hasNotAnyFlags)
{
void *memberObject = member->Data(object);
const DAVA::MetaInfo *memberMetaInfo = member->Type();
const DAVA::IntrospectionInfo *memberIntrospection = memberMetaInfo->GetIntrospection(memberObject);
bool isKeyedArchive = false;
// keyed archive
if(NULL != memberIntrospection && (memberIntrospection->Type() == DAVA::MetaInfo::Instance<DAVA::KeyedArchive>()))
{
QtPropertyDataDavaKeyedArcive *childData = new QtPropertyDataDavaKeyedArcive((DAVA::KeyedArchive *) memberObject);
ChildAdd(member->Name(), childData);
}
// introspection
else if(NULL != memberObject && NULL != memberIntrospection)
{
QtPropertyDataIntrospection *childData = new QtPropertyDataIntrospection(memberObject, memberIntrospection, hasAnyFlags, hasNotAnyFlags);
ChildAdd(member->Name(), childData);
}
// any other value
else
{
// pointer
if(memberMetaInfo->IsPointer())
{
QString s;
QtPropertyData* childData = new QtPropertyData(s.sprintf("[%p] Pointer", memberObject));
childData->SetFlags(childData->GetFlags() | FLAG_IS_DISABLED);
ChildAdd(member->Name(), childData);
}
// other value
else
{
// collection
if(member->Collection() && !isKeyedArchive)
{
QtPropertyDataIntroCollection *childCollection = new QtPropertyDataIntroCollection(memberObject, member->Collection(), hasAnyFlags, hasNotAnyFlags);
ChildAdd(member->Name(), childCollection);
}
// variant
else
{
QtPropertyDataDavaVariant *childData = new QtPropertyDataDavaVariant(member->Value(object));
if(member->Flags() & DAVA::INTROSPECTION_EDITOR_READONLY)
{
childData->SetFlags(childData->GetFlags() | FLAG_IS_NOT_EDITABLE);
}
ChildAdd(member->Name(), childData);
childVariantMembers.insert(childData, member);
}
}
}
}
示例4: GetValue
QVariant QtPropertyData::GetValue() const
{
QtPropertyData *self = const_cast<QtPropertyData*>(this);
if(curValue.isValid() || !curValue.isNull())
{
self->UpdateValue();
}
self->BuildCurrentValue();
return curValue;
}
示例5: QModelIndex
int QtPropertyModel::rowCount(const QModelIndex & parent /* = QModelIndex() */) const
{
int count = 0;
QtPropertyData *data = itemFromIndexInternal(parent);
if(NULL != data)
{
count = data->ChildCount();
}
return count;
}
示例6: hideAllChildOptionalWidgets
void QtPropertyItemDelegate::hideAllChildOptionalWidgets(QtPropertyData* data)
{
for(int i = 0; i < data->ChildCount(); i++)
{
QPair<QString, QtPropertyData *> childPair = data->ChildGet(i);
QtPropertyData *childData = childPair.second;
for (int j = 0; j < childData->GetOWCount(); j++)
{
childData->GetOW(j)->widget->hide();
}
hideAllChildOptionalWidgets(childData);
}
}
示例7: setModelData
void QtPropertyItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
const QtPropertyModel *propertyModel = dynamic_cast<const QtPropertyModel *>(index.model());
if(NULL != propertyModel)
{
QtPropertyItem* item = (QtPropertyItem*) propertyModel->itemFromIndex(index);
QtPropertyData* data = item->GetPropertyData();
if(NULL != data)
{
data->EditorDone(editor);
}
}
QStyledItemDelegate::setModelData(editor, model, index);
}
示例8: recalcOptionalWidgets
void QtPropertyItemDelegate::recalcOptionalWidgets(const QModelIndex &index, QStyleOptionViewItem *option) const
{
QtPropertyData* data = index.data(QtPropertyItem::PropertyDataRole).value<QtPropertyData*>();
if(NULL != data)
{
QWidget *owViewport = data->GetOWViewport();
int prevOWSpace = 0;
int owSpacing = 1;
int optionRectRight = option->rect.right();
int dataCount = data->GetOWCount();
for (int i = 0; i < dataCount; ++i)
{
const QtPropertyOW *ow = data->GetOW(i);
if(NULL != ow && NULL != owViewport && NULL != ow->widget)
{
QWidget *owWidget = ow->widget;
int owWidth = ow->size.width();
if(0 != owWidth)
{
QRect owRect = option->rect;
owRect.setLeft(optionRectRight - owWidth - prevOWSpace);
owRect.setRight(owRect.left() + owWidth);
owWidget->setGeometry(owRect);
owWidget->show();
// if this widget isn't overlayed we should modify rect for tree view cell to be drawn in.
if(!ow->overlay)
{
option->rect.setRight(owRect.left());
}
prevOWSpace += (owWidth + owSpacing);
}
else
{
owWidget->hide();
}
}
}
}
}
示例9: createEditor
QWidget* QtPropertyItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QWidget* editWidget = NULL;
QtPropertyData* data = index.data(QtPropertyItem::PropertyDataRole).value<QtPropertyData*>();
recalcOptionalWidgets(index, (QStyleOptionViewItem *) &option);
if(NULL != data)
{
editWidget = data->CreateEditor(parent, option);
}
if(NULL == editWidget)
{
editWidget = QStyledItemDelegate::createEditor(parent, option, index);
}
return editWidget;
}
示例10: indexFromItem
QModelIndex QtPropertyModel::indexFromItem(QtPropertyData *data) const
{
QModelIndex ret;
if(NULL != data)
{
QtPropertyData *parent = data->Parent();
if(NULL != parent)
{
int row = parent->ChildIndex(data);
if(row >= 0)
{
ret = createIndex(row, 0, parent);
}
}
}
return ret;
}
示例11: setEditorData
void QtPropertyItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
bool doneByInternalEditor = false;
const QtPropertyModel *propertyModel = dynamic_cast<const QtPropertyModel *>(index.model());
if(NULL != propertyModel)
{
QtPropertyItem* item = (QtPropertyItem*) propertyModel->itemFromIndex(index);
QtPropertyData* data = item->GetPropertyData();
if(NULL != data)
{
doneByInternalEditor = data->SetEditorData(editor);
}
}
if(!doneByInternalEditor)
{
QStyledItemDelegate::setEditorData(editor, index);
}
}
示例12: GetValueInternal
void QtPropertyData::BuildCurrentValue()
{
// Build value
const QVariant master = GetValueInternal();
bool isAllEqual = true;
isValuesMerged = false;
for ( int i = 0; i < mergedData.size(); i++ )
{
QtPropertyData *item = mergedData.at(i);
const QVariant slave = item->GetValue();
if (master != slave)
{
isAllEqual = false;
break;
}
}
curValue = isAllEqual ? master : QVariant();
isValuesMerged = isAllEqual;
// Update Qt MVC properties
if ( !isAllEqual )
{
QList<int> roles;
roles << Qt::DecorationRole;
for ( int iRole = 0; iRole < roles.size(); iRole++ )
{
const int role = roles.at(iRole);
auto it = style.find( role );
if ( it != style.end() )
{
*it = QVariant();
}
}
}
}
示例13: QtPropertyDataDavaKeyedArcive
void QtPropertyDataDavaKeyedArcive::ChildCreate(const QString &key, DAVA::VariantType *value)
{
QtPropertyData *childData = NULL;
if(value->type == DAVA::VariantType::TYPE_KEYED_ARCHIVE)
{
childData = new QtPropertyDataDavaKeyedArcive(value->AsKeyedArchive());
}
else
{
childData = new QtPropertyDataDavaVariant(*value);
}
ChildAdd(key, childData);
// add optional widget (button) to remove this key
QPushButton *remButton = new QPushButton(QIcon(":/QtIcons/keyminus.png"), "");
remButton->setIconSize(QSize(12, 12));
childData->AddOW(QtPropertyOW(remButton));
childData->SetOWViewport(GetOWViewport());
QObject::connect(remButton, SIGNAL(pressed()), this, SLOT(RemKeyedArchiveField()));
}
示例14: createEditor
QWidget* QtPropertyItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QWidget* editWidget = NULL;
const QtPropertyModel *propertyModel = dynamic_cast<const QtPropertyModel *>(index.model());
if(NULL != propertyModel)
{
QtPropertyItem* item = (QtPropertyItem*) propertyModel->itemFromIndex(index);
QtPropertyData* data = item->GetPropertyData();
if(NULL != data)
{
editWidget = data->CreateEditor(parent, option);
}
TryEditorWorkarounds(editWidget);
}
if(NULL == editWidget)
{
editWidget = QStyledItemDelegate::createEditor(parent, option, index);
}
return editWidget;
}
示例15: QtPropertyDataDavaKeyedArcive
void QtPropertyDataDavaKeyedArcive::ChildCreate(const QString &key, DAVA::VariantType *value)
{
QtPropertyData *childData = NULL;
if(value->type == DAVA::VariantType::TYPE_KEYED_ARCHIVE)
{
childData = new QtPropertyDataDavaKeyedArcive(value->AsKeyedArchive());
}
else
{
childData = new QtPropertyKeyedArchiveMember(curArchive, key.toStdString());
int presetValueType = EditorConfig::Instance()->GetPropertyValueType(key.toStdString());
if(presetValueType != DAVA::VariantType::TYPE_NONE)
{
if(value->type == presetValueType)
{
const DAVA::Vector<DAVA::String>& allowedValues = EditorConfig::Instance()->GetComboPropertyValues(key.toStdString());
for(size_t i = 0; i < allowedValues.size(); ++i)
{
((QtPropertyKeyedArchiveMember *) childData)->AddAllowedValue(DAVA::VariantType((int) i), allowedValues[i].c_str());
}
}
}
}
ChildAdd(key, childData);
// add optional widget (button) to remove this key
QPushButton *remButton = new QPushButton(QIcon(":/QtIcons/keyminus.png"), "");
remButton->setIconSize(QSize(12, 12));
childData->AddOW(QtPropertyOW(remButton));
childData->SetOWViewport(GetOWViewport());
QObject::connect(remButton, SIGNAL(pressed()), this, SLOT(RemKeyedArchiveField()));
}