本文整理汇总了C++中ModelNode::minorVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode::minorVersion方法的具体用法?C++ ModelNode::minorVersion怎么用?C++ ModelNode::minorVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelNode
的用法示例。
在下文中一共展示了ModelNode::minorVersion方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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"));
}
示例4: 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());
}
示例5: 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('}');
}
示例6: addNewTab
void AddTabDesignerAction::addNewTab()
{
QString tabName = AddTabToTabViewDialog::create(QStringLiteral("Tab"), Core::ICore::mainWindow());
if (!tabName.isEmpty()) {
QString directoryPath = QFileInfo(selectionContext().view()->model()->fileUrl().toLocalFile()).absolutePath();
QString newFilePath = directoryPath +QStringLiteral("/") + tabName + QStringLiteral(".qml");
if (QFileInfo::exists(newFilePath)) {
Core::AsynchronousMessageBox::warning(tr("Naming Error"), tr("Component already exists."));
} else {
const QString sourceString = QStringLiteral("import QtQuick 2.1\nimport QtQuick.Controls 1.0\n\nItem {\n anchors.fill: parent\n}");
bool fileCreated = DocumentManager::createFile(newFilePath, sourceString);
if (fileCreated) {
DocumentManager::addFileToVersionControl(directoryPath, newFilePath);
ModelNode tabViewModelNode = findTabViewModelNode(selectionContext().currentSingleSelectedNode());
PropertyListType propertyList;
propertyList.append(QPair<PropertyName, QVariant>("source", QString(tabName + QStringLiteral(".qml"))));
propertyList.append(QPair<PropertyName, QVariant>("title", tabName));
ModelNode newTabModelNode = selectionContext().view()->createModelNode("QtQuick.Controls.Tab",
tabViewModelNode.majorVersion(),
tabViewModelNode.minorVersion(),
propertyList);
newTabModelNode.setIdWithRefactoring(newTabModelNode.view()->generateNewId(tabName));
tabViewModelNode.defaultNodeAbstractProperty().reparentHere(newTabModelNode);
}
}
}
}
示例7: createNodeFromNode
static ModelNode createNodeFromNode(const ModelNode &modelNode,const QHash<QString, QString> &idRenamingHash, AbstractView *view)
{
QList<QPair<QString, QVariant> > propertyList;
QList<QPair<QString, QVariant> > variantPropertyList;
foreach (const VariantProperty &variantProperty, modelNode.variantProperties()) {
propertyList.append(QPair<QString, QVariant>(variantProperty.name(), variantProperty.value()));
}
ModelNode newNode(view->createModelNode(modelNode.type(),modelNode.majorVersion(),modelNode.minorVersion(),
propertyList, variantPropertyList, modelNode.nodeSource(), modelNode.nodeSourceType()));
syncBindingProperties(newNode, modelNode, idRenamingHash);
syncId(newNode, modelNode, idRenamingHash);
syncNodeProperties(newNode, modelNode, idRenamingHash, view);
syncNodeListProperties(newNode, modelNode, idRenamingHash, view);
return newNode;
}
示例8: addNewTab
void TabViewDesignerAction::addNewTab()
{
QString tabName = AddTabToTabViewDialog::create(QLatin1String("Tab"), Core::ICore::mainWindow());
if (!tabName.isEmpty()) {
QString directoryPath = QFileInfo(selectionContext().view()->model()->fileUrl().toLocalFile()).absolutePath();
QString newFilePath = directoryPath +QLatin1String("/") + tabName + QLatin1String(".qml");
if (QFileInfo(newFilePath).exists()) {
QMessageBox::warning(Core::ICore::mainWindow(), tr("Naming Error"), tr("Component already exists."));
} else {
bool fileCreated = createFile(newFilePath);
if (fileCreated) {
addNewFileToVersionControl(directoryPath, newFilePath);
ModelNode tabViewModelNode = findTabViewModelNode(selectionContext().currentSingleSelectedNode());
PropertyListType propertyList;
propertyList.append(QPair<PropertyName, QVariant>("source", QString(tabName + QLatin1String(".qml"))));
propertyList.append(QPair<PropertyName, QVariant>("title", tabName));
ModelNode newTabModelNode = selectionContext().view()->createModelNode("QtQuick.Controls.Tab",
tabViewModelNode.majorVersion(),
tabViewModelNode.minorVersion(),
propertyList);
newTabModelNode.setId(newTabModelNode.view()->generateNewId(tabName));
tabViewModelNode.defaultNodeAbstractProperty().reparentHere(newTabModelNode);
}
}
}
}