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


C++ QtPropertyData类代码示例

本文整理汇总了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;
}
开发者ID:galek,项目名称:dava.framework,代码行数:32,代码来源:QtPropertyModel.cpp

示例2: itemFromIndexInternal

void QtPropertyModel::MergeProperty(QtPropertyData* data, QModelIndex const& parent)
{
	if(NULL != data)
	{
		QtPropertyData *parentData = itemFromIndexInternal(parent);
		if(NULL != parentData)
		{
            parentData->MergeChild(data);
		}
	}
}
开发者ID:galek,项目名称:dava.framework,代码行数:11,代码来源:QtPropertyModel.cpp

示例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);
            }
        }
    }
}
开发者ID:boyjimeking,项目名称:dava.framework,代码行数:54,代码来源:QtPropertyDataIntrospection.cpp

示例4: GetValue

QVariant QtPropertyData::GetValue() const
{
    QtPropertyData *self = const_cast<QtPropertyData*>(this);
    
    if(curValue.isValid() || !curValue.isNull())
	{
		self->UpdateValue();
	}

    self->BuildCurrentValue();
	return curValue;
}
开发者ID:galek,项目名称:dava.framework,代码行数:12,代码来源:QtPropertyData.cpp

示例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;
}
开发者ID:galek,项目名称:dava.framework,代码行数:12,代码来源:QtPropertyModel.cpp

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

示例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);
}
开发者ID:abaradulkin,项目名称:dava.framework,代码行数:15,代码来源:QtPropertyItemDelegate.cpp

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

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

示例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;
}
开发者ID:galek,项目名称:dava.framework,代码行数:19,代码来源:QtPropertyModel.cpp

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

示例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();
            }
        }
    }

}
开发者ID:galek,项目名称:dava.framework,代码行数:38,代码来源:QtPropertyData.cpp

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

示例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;
}
开发者ID:abaradulkin,项目名称:dava.framework,代码行数:24,代码来源:QtPropertyItemDelegate.cpp

示例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()));
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:36,代码来源:QtPropertyDataDavaKeyedArchive.cpp


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