本文整理汇总了C++中ModelNode::model方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode::model方法的具体用法?C++ ModelNode::model怎么用?C++ ModelNode::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelNode
的用法示例。
在下文中一共展示了ModelNode::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replaceModel
void ModelMerger::replaceModel(const ModelNode &modelNode)
{
view()->model()->changeImports(modelNode.model()->imports(), QList<Import>());
view()->model()->setFileUrl(modelNode.model()->fileUrl());
try {
RewriterTransaction transaction(view()->beginRewriterTransaction());
ModelNode rootNode(view()->rootModelNode());
foreach (const QString &propertyName, rootNode.propertyNames())
rootNode.removeProperty(propertyName);
QHash<QString, QString> idRenamingHash;
setupIdRenamingHash(modelNode, idRenamingHash, view());
syncVariantProperties(rootNode, modelNode);
syncBindingProperties(rootNode, modelNode, idRenamingHash);
syncId(rootNode, modelNode, idRenamingHash);
syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
} catch (RewritingException &e) {
qWarning() << e.description(); //silent error
}
}
示例2: setObjectValue
bool ModelNode::setObjectValue(const QScriptValue& valuemap, bool writeToCache)
{
bool emitItemsChanged = false;
QScriptValueIterator it(valuemap);
while (it.hasNext()) {
it.next();
ModelNode *prev = properties.value(it.name());
ModelNode *value = new ModelNode(m_model);
QScriptValue v = it.value();
if (v.isArray()) {
value->isArray = true;
value->setListValue(v);
if (writeToCache && objectCache)
objectCache->setValue(it.name().toUtf8(), QVariant::fromValue(value->model(m_model)));
emitItemsChanged = true; // for now, too inefficient to check whether list and sublists have changed
} else {
value->values << v.toVariant();
if (writeToCache && objectCache)
objectCache->setValue(it.name().toUtf8(), value->values.last());
if (!emitItemsChanged && prev && prev->values.count() == 1
&& prev->values[0] != value->values.last()) {
emitItemsChanged = true;
}
}
if (properties.contains(it.name()))
delete properties[it.name()];
properties.insert(it.name(), value);
}
return emitItemsChanged;
}
示例3: openSourcePropertyOfLoader
static void openSourcePropertyOfLoader(const ModelNode &modelNode)
{
QmlDesignerPlugin::instance()->viewManager().nextFileIsCalledInternally();
QString componentFileName = modelNode.variantProperty("source").value().toString();
QFileInfo fileInfo(modelNode.model()->fileUrl().toLocalFile());
Core::EditorManager::openEditor(fileInfo.absolutePath() + "/" + componentFileName, Core::Id(), Core::EditorManager::DoNotMakeVisible);
}
示例4: paint
void NameItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (option.state & QStyle::State_Selected)
drawSelectionBackground(painter, option);
QString displayString;
QPoint displayStringOffset;
painter->save();
QFontMetrics fm(option.font);
int width = 0;
if (index.data(Qt::UserRole).isValid()) {
int pixmapSide = 16;
if (m_TreeModel->isNodeInvisible( index ))
painter->setOpacity(0.5);
ModelNode node = m_TreeModel->nodeForIndex(index);
QIcon icon;
if (node.isValid()) {
// if node has no own icon, search for it in the itemlibrary
const ItemLibraryInfo *libraryInfo = node.model()->metaInfo().itemLibraryInfo();
QList <ItemLibraryEntry> infoList = libraryInfo->entriesForType(node.type(),
node.majorVersion(),
node.minorVersion());
foreach (const ItemLibraryEntry &entry, infoList) {
if (icon.isNull()) {
icon = entry.icon();
break;
}
}
}
// if the library was also empty, use the default icon
if (icon.isNull())
icon = QIcon(QLatin1String(":/ItemLibrary/images/item-default-icon.png"));
if (!node.metaInfo().isValid())
icon = QIcon(QLatin1String(":/ItemLibrary/images/item-invalid-icon.png"));
// If no icon is present, leave an empty space of 24 pixels anyway
QPixmap pixmap = icon.pixmap(pixmapSide, pixmapSide);
painter->drawPixmap(option.rect.x()+1,option.rect.y()+2,pixmap);
displayString = node.id();
if (displayString.isEmpty())
displayString = node.simplifiedTypeName();
// Check text length does not exceed available space
int extraSpace=12+pixmapSide;
displayString = fm.elidedText(displayString,Qt::ElideMiddle,option.rect.width()-extraSpace);
displayStringOffset = QPoint(5+pixmapSide,-5);
width = fm.width(displayString);
}
示例5: replaceModel
void ModelMerger::replaceModel(const ModelNode &modelNode)
{
RewriterTransaction transaction(view()->beginRewriterTransaction());
foreach (const Import &import, modelNode.model()->imports())
view()->model()->addImport(import);
view()->model()->setFileUrl(modelNode.model()->fileUrl());
ModelNode rootNode(view()->rootModelNode());
foreach (const QString &propertyName, rootNode.propertyNames())
rootNode.removeProperty(propertyName);
QHash<QString, QString> idRenamingHash;
setupIdRenamingHash(modelNode, idRenamingHash, view());
syncVariantProperties(rootNode, modelNode);
syncBindingProperties(rootNode, modelNode, idRenamingHash);
syncId(rootNode, modelNode, idRenamingHash);
syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
}
示例6: insertModel
ModelNode ModelMerger::insertModel(const ModelNode &modelNode)
{
RewriterTransaction transaction(view()->beginRewriterTransaction());
foreach (const Import &import, modelNode.model()->imports())
view()->model()->addImport(import);
QHash<QString, QString> idRenamingHash;
setupIdRenamingHash(modelNode, idRenamingHash, view());
qDebug() << idRenamingHash;
ModelNode newNode(createNodeFromNode(modelNode, idRenamingHash, view()));
return newNode;
}
示例7: openSourcePropertyOfLoader
static void openSourcePropertyOfLoader(const ModelNode &modelNode)
{
QmlDesignerPlugin::instance()->viewManager().nextFileIsCalledInternally();
QHash<PropertyName, QVariant> propertyHash;
QString componentFileName = modelNode.variantProperty("source").value().toString();
QString componentFilePath = modelNode.model()->fileUrl().resolved(QUrl::fromLocalFile(componentFileName)).toLocalFile();
getProperties(modelNode, propertyHash);
Core::EditorManager::openEditor(componentFilePath, Core::Id(), Core::EditorManager::DoNotMakeVisible);
ModelNode rootModelNode = currentDesignDocument()->rewriterView()->rootModelNode();
applyProperties(rootModelNode, propertyHash);
}
示例8: insertModel
ModelNode ModelMerger::insertModel(const ModelNode &modelNode)
{
RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::insertModel")));
QList<Import> newImports;
foreach (const Import &import, modelNode.model()->imports()) {
if (!view()->model()->hasImport(import, true, true))
newImports.append(import);
}
view()->model()->changeImports(newImports, QList<Import>());
QHash<QString, QString> idRenamingHash;
setupIdRenamingHash(modelNode, idRenamingHash, view());
ModelNode newNode(createNodeFromNode(modelNode, idRenamingHash, view()));
return newNode;
}
示例9: getTypeIcon
static QIcon getTypeIcon(const ModelNode &modelNode)
{
QIcon icon;
if (modelNode.isValid()) {
// if node has no own icon, search for it in the itemlibrary
const ItemLibraryInfo *libraryInfo = modelNode.model()->metaInfo().itemLibraryInfo();
QList <ItemLibraryEntry> itemLibraryEntryList = libraryInfo->entriesForType(modelNode.type(),
modelNode.majorVersion(),
modelNode.minorVersion());
if (!itemLibraryEntryList.isEmpty())
return itemLibraryEntryList.first().typeIcon();
else if (modelNode.metaInfo().isValid())
return QIcon(QStringLiteral(":/ItemLibrary/images/item-default-icon.png"));
else
return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png"));
}
return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png"));
}
示例10: valueForNode
QVariant NestedListModel::valueForNode(ModelNode *node, bool *hasNested) const
{
QObject *rv = 0;
if (hasNested)
*hasNested = false;
if (node->isArray) {
// List
rv = node->model(this);
if (hasNested)
*hasNested = true;
} else {
if (!node->properties.isEmpty()) {
// Object
rv = node->object(this);
} else if (node->values.count() == 0) {
// Invalid
return QVariant();
} else if (node->values.count() == 1) {
// Value
QVariant &var = node->values[0];
ModelNode *valueNode = qvariant_cast<ModelNode *>(var);
if (valueNode) {
if (!valueNode->properties.isEmpty())
rv = valueNode->object(this);
else
rv = valueNode->model(this);
} else {
return var;
}
}
}
if (rv) {
return QVariant::fromValue(rv);
} else {
return QVariant();
}
}
示例11: toQml
QString QmlTextGenerator::toQml(const ModelNode &node, int indentDepth) const
{
QString type = node.type();
QString url;
if (type.contains('.')) {
QStringList nameComponents = type.split('.');
url = nameComponents.first();
type = nameComponents.last();
}
QString alias;
if (!url.isEmpty()) {
foreach (const Import &import, node.model()->imports()) {
if (import.url() == url) {
alias = import.alias();
break;
}
if (import.file() == url) {
alias = import.alias();
break;
}
}
}
示例12: toQml
QString QmlTextGenerator::toQml(const ModelNode &node, int indentDepth) const
{
QString type = node.type();
QString url;
if (type.contains('.')) {
QStringList nameComponents = type.split('.');
url = nameComponents.first();
type = nameComponents.last();
}
QString alias;
if (!url.isEmpty()) {
const QString &versionUrl = QString("%1.%2").arg(QString::number(node.majorVersion()), QString::number(node.minorVersion()));
foreach (const Import &import, node.model()->imports()) {
if (import.url() == url
&& import.version() == versionUrl) {
alias = import.alias();
break;
}
}
}
QString result;
if (!alias.isEmpty())
result = alias + '.';
result += type;
result += QLatin1String(" {\n");
const int propertyIndentDepth = indentDepth + 4;
const QString properties = propertiesToQml(node, propertyIndentDepth);
return result + properties + QString(indentDepth, QLatin1Char(' ')) + QLatin1Char('}');
}
示例13: ModelNode
scene::Node& MDLModel_default(){
ModelNode* modelNode = new ModelNode();
Model_constructNull( modelNode->model() );
return modelNode->node();
}
示例14: ModelNode
scene::Node& MD2Model_new( const byte* buffer, ArchiveFile& file ){
ModelNode* modelNode = new ModelNode();
MD2Model_read( modelNode->model(), buffer, file );
return modelNode->node();
}
示例15: ModelNode
scene::Node& MDCModel_new(const byte* buffer)
{
ModelNode* modelNode = new ModelNode();
MDCModel_read(modelNode->model(), buffer);
return modelNode->node();
}