forked from qt-creator/qt-creator
QmlDesigner: Avoid detachs
The non const overloads of first() and last() do detach if the reference count is higher than 1. Therefore we use constFirst() and constLast() instead. Change-Id: I737cfc428f1c21f16185b9b51175e181c0ec7068 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -54,7 +54,7 @@ Enumeration::Enumeration(const QString &scope, const QString &name)
|
|||||||
|
|
||||||
QmlDesigner::EnumerationName QmlDesigner::Enumeration::scope() const
|
QmlDesigner::EnumerationName QmlDesigner::Enumeration::scope() const
|
||||||
{
|
{
|
||||||
return m_enumerationName.split('.').first();
|
return m_enumerationName.split('.').constFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumerationName Enumeration::name() const
|
EnumerationName Enumeration::name() const
|
||||||
|
@@ -359,7 +359,7 @@ bool selectionHasSameParentAndInBaseState(const SelectionContext &context)
|
|||||||
bool isNotInLayout(const SelectionContext &context)
|
bool isNotInLayout(const SelectionContext &context)
|
||||||
{
|
{
|
||||||
if (selectionNotEmpty(context)) {
|
if (selectionNotEmpty(context)) {
|
||||||
ModelNode selectedModelNode = context.selectedModelNodes().first();
|
const ModelNode &selectedModelNode = context.selectedModelNodes().constFirst();
|
||||||
ModelNode parentModelNode;
|
ModelNode parentModelNode;
|
||||||
|
|
||||||
if (selectedModelNode.hasParentProperty())
|
if (selectedModelNode.hasParentProperty())
|
||||||
|
@@ -130,7 +130,7 @@ protected:
|
|||||||
if (m_insideObject) {
|
if (m_insideObject) {
|
||||||
QStringList stringList = textAt(node->qualifiedId->firstSourceLocation(),
|
QStringList stringList = textAt(node->qualifiedId->firstSourceLocation(),
|
||||||
node->qualifiedId->lastSourceLocation()).split(QLatin1String("."));
|
node->qualifiedId->lastSourceLocation()).split(QLatin1String("."));
|
||||||
const QString itemid = stringList.isEmpty() ? QString() : stringList.first();
|
const QString itemid = stringList.isEmpty() ? QString() : stringList.constFirst();
|
||||||
|
|
||||||
if (itemid == m_itemId) {
|
if (itemid == m_itemId) {
|
||||||
m_implemenations.append(node->statement->firstSourceLocation());
|
m_implemenations.append(node->statement->firstSourceLocation());
|
||||||
|
@@ -57,7 +57,7 @@ static int findFirstBigger(const QVector<int> &v, int tolerance)
|
|||||||
if (v.isEmpty())
|
if (v.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int last = v.first();
|
int last = v.constFirst();
|
||||||
for (int i = 0; i < v.length(); ++i) {
|
for (int i = 0; i < v.length(); ++i) {
|
||||||
if (v.value(i) > last + tolerance)
|
if (v.value(i) > last + tolerance)
|
||||||
return i;
|
return i;
|
||||||
@@ -257,7 +257,7 @@ void LayoutInGridLayout::collectItemNodes()
|
|||||||
m_qmlItemNodes.append(itemNode);
|
m_qmlItemNodes.append(itemNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_parentNode = m_qmlItemNodes.first().instanceParentItem();
|
m_parentNode = m_qmlItemNodes.constFirst().instanceParentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutInGridLayout::collectOffsets()
|
void LayoutInGridLayout::collectOffsets()
|
||||||
@@ -287,10 +287,10 @@ void LayoutInGridLayout::sortOffsets()
|
|||||||
void LayoutInGridLayout::calculateGridOffsets()
|
void LayoutInGridLayout::calculateGridOffsets()
|
||||||
{
|
{
|
||||||
if (!m_xTopOffsets.isEmpty())
|
if (!m_xTopOffsets.isEmpty())
|
||||||
m_startX = m_xTopOffsets.first();
|
m_startX = m_xTopOffsets.constFirst();
|
||||||
|
|
||||||
if (!m_yTopOffsets.isEmpty())
|
if (!m_yTopOffsets.isEmpty())
|
||||||
m_startY = m_yTopOffsets.first();
|
m_startY = m_yTopOffsets.constFirst();
|
||||||
|
|
||||||
const int defaultWidthTolerance = 64;
|
const int defaultWidthTolerance = 64;
|
||||||
const int defaultHeightTolerance = 64;
|
const int defaultHeightTolerance = 64;
|
||||||
|
@@ -40,7 +40,7 @@ static inline bool itemsHaveSameParent(const QList<ModelNode> &siblingList)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
QmlItemNode item(siblingList.first());
|
const QmlItemNode &item = siblingList.constFirst();
|
||||||
if (!item.isValid())
|
if (!item.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@@ -285,7 +285,7 @@ void setVisible(const SelectionContext &selectionState)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
selectionState.selectedModelNodes().first().variantProperty("visible").setValue(selectionState.toggled());
|
selectionState.selectedModelNodes().constFirst().variantProperty("visible").setValue(selectionState.toggled());
|
||||||
} catch (const RewritingException &e) { //better save then sorry
|
} catch (const RewritingException &e) { //better save then sorry
|
||||||
e.showException();
|
e.showException();
|
||||||
}
|
}
|
||||||
@@ -657,7 +657,7 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
|||||||
{
|
{
|
||||||
ModelNode modelNode;
|
ModelNode modelNode;
|
||||||
if (selectionState.singleNodeIsSelected())
|
if (selectionState.singleNodeIsSelected())
|
||||||
modelNode = selectionState.selectedModelNodes().first();
|
modelNode = selectionState.selectedModelNodes().constFirst();
|
||||||
|
|
||||||
bool isModelNodeRoot = true;
|
bool isModelNodeRoot = true;
|
||||||
|
|
||||||
@@ -690,7 +690,7 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
|||||||
const QString fileName = currentDesignDocument.toString();
|
const QString fileName = currentDesignDocument.toString();
|
||||||
const QString typeName = currentDesignDocument.toFileInfo().baseName();
|
const QString typeName = currentDesignDocument.toFileInfo().baseName();
|
||||||
|
|
||||||
QStringList signalNames = cleanSignalNames(getSortedSignalNameList(selectionState.selectedModelNodes().first()));
|
QStringList signalNames = cleanSignalNames(getSortedSignalNameList(selectionState.selectedModelNodes().constFirst()));
|
||||||
|
|
||||||
QList<QmlJSEditor::FindReferences::Usage> usages = QmlJSEditor::FindReferences::findUsageOfType(fileName, typeName);
|
QList<QmlJSEditor::FindReferences::Usage> usages = QmlJSEditor::FindReferences::findUsageOfType(fileName, typeName);
|
||||||
|
|
||||||
@@ -701,12 +701,12 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
usages = FindImplementation::run(usages.first().path, typeName, itemId);
|
usages = FindImplementation::run(usages.constFirst().path, typeName, itemId);
|
||||||
|
|
||||||
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
||||||
|
|
||||||
if (usages.count() > 0 && (addAlwaysNewSlot || usages.count() < 2) && (!isModelNodeRoot || addAlwaysNewSlot)) {
|
if (usages.count() > 0 && (addAlwaysNewSlot || usages.count() < 2) && (!isModelNodeRoot || addAlwaysNewSlot)) {
|
||||||
Core::EditorManager::openEditorAt(usages.first().path, usages.first().line, usages.first().col);
|
Core::EditorManager::openEditorAt(usages.constFirst().path, usages.constFirst().line, usages.constFirst().col);
|
||||||
|
|
||||||
if (!signalNames.isEmpty()) {
|
if (!signalNames.isEmpty()) {
|
||||||
AddSignalHandlerDialog *dialog = new AddSignalHandlerDialog(Core::ICore::dialogParent());
|
AddSignalHandlerDialog *dialog = new AddSignalHandlerDialog(Core::ICore::dialogParent());
|
||||||
@@ -732,7 +732,7 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
|||||||
//Move cursor to correct curser position
|
//Move cursor to correct curser position
|
||||||
const QString filePath = Core::EditorManager::currentDocument()->filePath().toString();
|
const QString filePath = Core::EditorManager::currentDocument()->filePath().toString();
|
||||||
QList<QmlJSEditor::FindReferences::Usage> usages = FindImplementation::run(filePath, typeName, itemId);
|
QList<QmlJSEditor::FindReferences::Usage> usages = FindImplementation::run(filePath, typeName, itemId);
|
||||||
Core::EditorManager::openEditorAt(filePath, usages.first().line, usages.first().col + 1);
|
Core::EditorManager::openEditorAt(filePath, usages.constFirst().line, usages.constFirst().col + 1);
|
||||||
} );
|
} );
|
||||||
dialog->show();
|
dialog->show();
|
||||||
|
|
||||||
@@ -740,7 +740,7 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::EditorManager::openEditorAt(usages.first().path, usages.first().line, usages.first().col + 1);
|
Core::EditorManager::openEditorAt(usages.constFirst().path, usages.constFirst().line, usages.constFirst().col + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeLayout(const SelectionContext &selectionContext)
|
void removeLayout(const SelectionContext &selectionContext)
|
||||||
@@ -794,7 +794,7 @@ void moveToComponent(const SelectionContext &selectionContext)
|
|||||||
{
|
{
|
||||||
ModelNode modelNode;
|
ModelNode modelNode;
|
||||||
if (selectionContext.singleNodeIsSelected())
|
if (selectionContext.singleNodeIsSelected())
|
||||||
modelNode = selectionContext.selectedModelNodes().first();
|
modelNode = selectionContext.selectedModelNodes().constFirst();
|
||||||
|
|
||||||
if (modelNode.isValid())
|
if (modelNode.isValid())
|
||||||
selectionContext.view()->model()->rewriterView()->moveToComponent(modelNode);
|
selectionContext.view()->model()->rewriterView()->moveToComponent(modelNode);
|
||||||
|
@@ -396,7 +396,7 @@ void DebugView::instancesChildrenChanged(const QVector<ModelNode> & nodeList)
|
|||||||
void DebugView::customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data)
|
void DebugView::customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data)
|
||||||
{
|
{
|
||||||
if (identifier == "PuppetStatus" && data.count() == 1) {
|
if (identifier == "PuppetStatus" && data.count() == 1) {
|
||||||
m_debugViewWidget->setPuppetStatus(data.first().toString());
|
m_debugViewWidget->setPuppetStatus(data.constFirst().toString());
|
||||||
|
|
||||||
} else if (isDebugViewEnabled()) {
|
} else if (isDebugViewEnabled()) {
|
||||||
QTextStream message;
|
QTextStream message;
|
||||||
|
@@ -265,7 +265,7 @@ void AbstractFormEditorTool::mouseReleaseEvent(const QList<QGraphicsItem*> & ite
|
|||||||
QmlItemNode currentSelectedNode;
|
QmlItemNode currentSelectedNode;
|
||||||
|
|
||||||
if (view()->selectedModelNodes().count() == 1) {
|
if (view()->selectedModelNodes().count() == 1) {
|
||||||
currentSelectedNode = view()->selectedModelNodes().first();
|
currentSelectedNode = view()->selectedModelNodes().constFirst();
|
||||||
|
|
||||||
if (!containsItemNode(itemList, currentSelectedNode)) {
|
if (!containsItemNode(itemList, currentSelectedNode)) {
|
||||||
QmlItemNode selectedNode;
|
QmlItemNode selectedNode;
|
||||||
|
@@ -89,7 +89,7 @@ void AnchorIndicator::setItems(const QList<FormEditorItem *> &itemList)
|
|||||||
clear();
|
clear();
|
||||||
|
|
||||||
if (itemList.count() == 1) {
|
if (itemList.count() == 1) {
|
||||||
m_formEditorItem = itemList.first();
|
m_formEditorItem = itemList.constFirst();
|
||||||
QmlItemNode sourceQmlItemNode = m_formEditorItem->qmlItemNode();
|
QmlItemNode sourceQmlItemNode = m_formEditorItem->qmlItemNode();
|
||||||
if (!sourceQmlItemNode.modelNode().isRootNode()) {
|
if (!sourceQmlItemNode.modelNode().isRootNode()) {
|
||||||
QmlAnchors qmlAnchors = sourceQmlItemNode.anchors();
|
QmlAnchors qmlAnchors = sourceQmlItemNode.anchors();
|
||||||
|
@@ -116,7 +116,7 @@ void BindingIndicator::setItems(const QList<FormEditorItem *> &itemList)
|
|||||||
clear();
|
clear();
|
||||||
|
|
||||||
if (itemList.count() == 1) {
|
if (itemList.count() == 1) {
|
||||||
m_formEditorItem = itemList.first();
|
m_formEditorItem = itemList.constFirst();
|
||||||
const QmlItemNode qmlItemNode = m_formEditorItem->qmlItemNode();
|
const QmlItemNode qmlItemNode = m_formEditorItem->qmlItemNode();
|
||||||
|
|
||||||
if (qmlItemNode.hasBindingProperty("x")) {
|
if (qmlItemNode.hasBindingProperty("x")) {
|
||||||
|
@@ -200,8 +200,8 @@ void FormEditorScene::dropEvent(QGraphicsSceneDragDropEvent * event)
|
|||||||
{
|
{
|
||||||
currentTool()->dropEvent(removeLayerItems(itemsAt(event->scenePos())), event);
|
currentTool()->dropEvent(removeLayerItems(itemsAt(event->scenePos())), event);
|
||||||
|
|
||||||
if (views().first())
|
if (views().constFirst())
|
||||||
views().first()->setFocus();
|
views().constFirst()->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorScene::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
|
void FormEditorScene::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
|
||||||
@@ -237,7 +237,7 @@ QList<QGraphicsItem *> FormEditorScene::itemsAt(const QPointF &pos)
|
|||||||
QTransform transform;
|
QTransform transform;
|
||||||
|
|
||||||
if (!views().isEmpty())
|
if (!views().isEmpty())
|
||||||
transform = views().first()->transform();
|
transform = views().constFirst()->transform();
|
||||||
|
|
||||||
return items(pos,
|
return items(pos,
|
||||||
Qt::IntersectsItemShape,
|
Qt::IntersectsItemShape,
|
||||||
|
@@ -397,7 +397,7 @@ void FormEditorView::changeToCustomTool()
|
|||||||
int handlingRank = 0;
|
int handlingRank = 0;
|
||||||
AbstractCustomTool *selectedCustomTool = 0;
|
AbstractCustomTool *selectedCustomTool = 0;
|
||||||
|
|
||||||
ModelNode selectedModelNode = selectedModelNodes().first();
|
const ModelNode &selectedModelNode = selectedModelNodes().constFirst();
|
||||||
|
|
||||||
foreach (AbstractCustomTool *customTool, m_customToolList) {
|
foreach (AbstractCustomTool *customTool, m_customToolList) {
|
||||||
if (customTool->wantHandleItem(selectedModelNode) > handlingRank) {
|
if (customTool->wantHandleItem(selectedModelNode) > handlingRank) {
|
||||||
|
@@ -75,10 +75,10 @@ void MoveManipulator::setItems(const QList<FormEditorItem*> &itemList)
|
|||||||
{
|
{
|
||||||
m_itemList = itemList;
|
m_itemList = itemList;
|
||||||
if (!m_itemList.isEmpty()) {
|
if (!m_itemList.isEmpty()) {
|
||||||
if (m_itemList.first()->parentItem())
|
if (m_itemList.constFirst()->parentItem())
|
||||||
m_snapper.setContainerFormEditorItem(m_itemList.first()->parentItem());
|
m_snapper.setContainerFormEditorItem(m_itemList.constFirst()->parentItem());
|
||||||
else
|
else
|
||||||
m_snapper.setContainerFormEditorItem(m_itemList.first());
|
m_snapper.setContainerFormEditorItem(m_itemList.constFirst());
|
||||||
m_snapper.setTransformtionSpaceFormEditorItem(m_snapper.containerFormEditorItem());
|
m_snapper.setTransformtionSpaceFormEditorItem(m_snapper.containerFormEditorItem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,8 +105,8 @@ void MoveManipulator::synchronizeParent(const QList<FormEditorItem*> &itemList,
|
|||||||
|
|
||||||
void MoveManipulator::synchronizeInstanceParent(const QList<FormEditorItem*> &itemList)
|
void MoveManipulator::synchronizeInstanceParent(const QList<FormEditorItem*> &itemList)
|
||||||
{
|
{
|
||||||
if (m_view->model() && !m_itemList.isEmpty() && m_itemList.first()->qmlItemNode().hasInstanceParent())
|
if (m_view->model() && !m_itemList.isEmpty() && m_itemList.constFirst()->qmlItemNode().hasInstanceParent())
|
||||||
synchronizeParent(itemList, m_itemList.first()->qmlItemNode().instanceParent());
|
synchronizeParent(itemList, m_itemList.constFirst()->qmlItemNode().instanceParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveManipulator::itemsCanReparented() const
|
bool MoveManipulator::itemsCanReparented() const
|
||||||
|
@@ -106,10 +106,10 @@ void MoveTool::mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
|
|||||||
|
|
||||||
FormEditorItem *containerItem = containerFormEditorItem(itemList, m_movingItems);
|
FormEditorItem *containerItem = containerFormEditorItem(itemList, m_movingItems);
|
||||||
if (containerItem && view()->currentState().isBaseState()) {
|
if (containerItem && view()->currentState().isBaseState()) {
|
||||||
if (containerItem != m_movingItems.first()->parentItem()
|
if (containerItem != m_movingItems.constFirst()->parentItem()
|
||||||
&& event->modifiers().testFlag(Qt::ShiftModifier)) {
|
&& event->modifiers().testFlag(Qt::ShiftModifier)) {
|
||||||
|
|
||||||
FormEditorItem *movingItem = m_movingItems.first();
|
const FormEditorItem *movingItem = m_movingItems.constFirst();
|
||||||
|
|
||||||
if (m_movingItems.count() > 1
|
if (m_movingItems.count() > 1
|
||||||
|| (movingItem->qmlItemNode().canBereparentedTo(containerItem->qmlItemNode())))
|
|| (movingItem->qmlItemNode().canBereparentedTo(containerItem->qmlItemNode())))
|
||||||
@@ -129,7 +129,7 @@ void MoveTool::hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.first());
|
ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.constFirst());
|
||||||
if (resizeHandle) {
|
if (resizeHandle) {
|
||||||
view()->changeToResizeTool();
|
view()->changeToResizeTool();
|
||||||
return;
|
return;
|
||||||
@@ -289,7 +289,7 @@ bool MoveTool::haveSameParent(const QList<FormEditorItem*> &itemList)
|
|||||||
if (itemList.isEmpty())
|
if (itemList.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QGraphicsItem *firstParent = itemList.first()->parentItem();
|
QGraphicsItem *firstParent = itemList.constFirst()->parentItem();
|
||||||
foreach (FormEditorItem* item, itemList)
|
foreach (FormEditorItem* item, itemList)
|
||||||
{
|
{
|
||||||
if (firstParent != item->parentItem())
|
if (firstParent != item->parentItem())
|
||||||
|
@@ -53,17 +53,17 @@ double OneDimensionalCluster::mean() const
|
|||||||
|
|
||||||
if (m_coordinateList.size() == 1)
|
if (m_coordinateList.size() == 1)
|
||||||
{
|
{
|
||||||
return m_coordinateList.first();
|
return m_coordinateList.constFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum(m_coordinateList) / m_coordinateList.size();
|
return sum(m_coordinateList) / m_coordinateList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
double OneDimensionalCluster::first() const
|
double OneDimensionalCluster::constFirst() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_coordinateList.isEmpty());
|
Q_ASSERT(!m_coordinateList.isEmpty());
|
||||||
|
|
||||||
return m_coordinateList.first();
|
return m_coordinateList.constFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<OneDimensionalCluster> OneDimensionalCluster::createOneDimensionalClusterList(const QList<double> & oneDimensionalCoordinateList)
|
QList<OneDimensionalCluster> OneDimensionalCluster::createOneDimensionalClusterList(const QList<double> & oneDimensionalCoordinateList)
|
||||||
@@ -136,7 +136,7 @@ QList<double> OneDimensionalCluster::reduceLines(const QList<double> & oneDimens
|
|||||||
|
|
||||||
QList<double> lineList;
|
QList<double> lineList;
|
||||||
foreach (const OneDimensionalCluster &cluster, clusterList)
|
foreach (const OneDimensionalCluster &cluster, clusterList)
|
||||||
lineList.append(cluster.first());
|
lineList.append(cluster.constFirst());
|
||||||
|
|
||||||
return lineList;
|
return lineList;
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ private:
|
|||||||
|
|
||||||
OneDimensionalCluster(const QList<double> & coordinateList );
|
OneDimensionalCluster(const QList<double> & coordinateList );
|
||||||
double mean() const;
|
double mean() const;
|
||||||
double first() const;
|
double constFirst() const;
|
||||||
|
|
||||||
static QList<OneDimensionalCluster> createOneDimensionalClusterList(const QList<double> & oneDimensionalCoordinateList);
|
static QList<OneDimensionalCluster> createOneDimensionalClusterList(const QList<double> & oneDimensionalCoordinateList);
|
||||||
static QList<OneDimensionalCluster> reduceOneDimensionalClusterList(const QList<OneDimensionalCluster> & unreducedClusterList, double maximumDistance);
|
static QList<OneDimensionalCluster> reduceOneDimensionalClusterList(const QList<OneDimensionalCluster> & unreducedClusterList, double maximumDistance);
|
||||||
|
@@ -58,7 +58,7 @@ void ResizeTool::mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
|||||||
if (itemList.isEmpty())
|
if (itemList.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ResizeHandleItem *resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.first());
|
ResizeHandleItem *resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.constFirst());
|
||||||
if (resizeHandle && resizeHandle->resizeController().isValid()) {
|
if (resizeHandle && resizeHandle->resizeController().isValid()) {
|
||||||
m_resizeManipulator.setHandle(resizeHandle);
|
m_resizeManipulator.setHandle(resizeHandle);
|
||||||
m_resizeManipulator.begin(event->scenePos());
|
m_resizeManipulator.begin(event->scenePos());
|
||||||
@@ -85,7 +85,7 @@ void ResizeTool::hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.first());
|
ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.constFirst());
|
||||||
if (resizeHandle && resizeHandle->resizeController().isValid()) {
|
if (resizeHandle && resizeHandle->resizeController().isValid()) {
|
||||||
m_resizeManipulator.setHandle(resizeHandle);
|
m_resizeManipulator.setHandle(resizeHandle);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -82,8 +82,8 @@ static QPolygonF boundingRectInLayerItemSpaceForItem(FormEditorItem *item, QGrap
|
|||||||
static bool checkSingleSelection(const QList<FormEditorItem*> &itemList)
|
static bool checkSingleSelection(const QList<FormEditorItem*> &itemList)
|
||||||
{
|
{
|
||||||
return !itemList.isEmpty()
|
return !itemList.isEmpty()
|
||||||
&& itemList.first()
|
&& itemList.constFirst()
|
||||||
&& itemList.first()->qmlItemNode().view()->singleSelectedModelNode().isValid();
|
&& itemList.constFirst()->qmlItemNode().view()->singleSelectedModelNode().isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int labelHeight = 16;
|
const int labelHeight = 16;
|
||||||
@@ -112,7 +112,7 @@ void SelectionIndicator::setItems(const QList<FormEditorItem*> &itemList)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (checkSingleSelection(itemList)) {
|
if (checkSingleSelection(itemList)) {
|
||||||
FormEditorItem *selectedItem = itemList.first();
|
FormEditorItem *selectedItem = itemList.constFirst();
|
||||||
m_labelItem.reset(new QGraphicsPolygonItem(m_layerItem.data()));
|
m_labelItem.reset(new QGraphicsPolygonItem(m_layerItem.data()));
|
||||||
|
|
||||||
QGraphicsWidget *toolbar = DesignerActionManager::instance().createFormEditorToolBar(m_labelItem.get());
|
QGraphicsWidget *toolbar = DesignerActionManager::instance().createFormEditorToolBar(m_labelItem.get());
|
||||||
@@ -161,7 +161,7 @@ void SelectionIndicator::updateItems(const QList<FormEditorItem*> &itemList)
|
|||||||
|
|
||||||
if (checkSingleSelection(itemList)
|
if (checkSingleSelection(itemList)
|
||||||
&& m_labelItem) {
|
&& m_labelItem) {
|
||||||
FormEditorItem *selectedItem = itemList.first();
|
FormEditorItem *selectedItem = itemList.constFirst();
|
||||||
QPolygonF labelPolygon = boundingRectInLayerItemSpaceForItem(selectedItem, m_layerItem.data());
|
QPolygonF labelPolygon = boundingRectInLayerItemSpaceForItem(selectedItem, m_layerItem.data());
|
||||||
QRectF labelRect = labelPolygon.boundingRect();
|
QRectF labelRect = labelPolygon.boundingRect();
|
||||||
QPointF pos = labelRect.topLeft();
|
QPointF pos = labelRect.topLeft();
|
||||||
|
@@ -126,7 +126,7 @@ void SelectionTool::hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
|||||||
{
|
{
|
||||||
if (!itemList.isEmpty()) {
|
if (!itemList.isEmpty()) {
|
||||||
|
|
||||||
ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.first());
|
ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.constFirst());
|
||||||
if (resizeHandle) {
|
if (resizeHandle) {
|
||||||
view()->changeToResizeTool();
|
view()->changeToResizeTool();
|
||||||
return;
|
return;
|
||||||
|
@@ -449,7 +449,7 @@ double Snapper::snappingDistance() const
|
|||||||
static QLineF mergedHorizontalLine(const QList<QLineF> &lineList)
|
static QLineF mergedHorizontalLine(const QList<QLineF> &lineList)
|
||||||
{
|
{
|
||||||
if (lineList.count() == 1)
|
if (lineList.count() == 1)
|
||||||
return lineList.first();
|
return lineList.constFirst();
|
||||||
|
|
||||||
double minimumX = std::numeric_limits<double>::max();
|
double minimumX = std::numeric_limits<double>::max();
|
||||||
double maximumX = std::numeric_limits<double>::min();
|
double maximumX = std::numeric_limits<double>::min();
|
||||||
@@ -460,14 +460,14 @@ static QLineF mergedHorizontalLine(const QList<QLineF> &lineList)
|
|||||||
maximumX = qMax(maximumX, double(line.x2()));
|
maximumX = qMax(maximumX, double(line.x2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
double y(lineList.first().y1());
|
double y(lineList.constFirst().y1());
|
||||||
return QLineF(minimumX, y, maximumX, y);
|
return QLineF(minimumX, y, maximumX, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QLineF mergedVerticalLine(const QList<QLineF> &lineList)
|
static QLineF mergedVerticalLine(const QList<QLineF> &lineList)
|
||||||
{
|
{
|
||||||
if (lineList.count() == 1)
|
if (lineList.count() == 1)
|
||||||
return lineList.first();
|
return lineList.constFirst();
|
||||||
|
|
||||||
double minimumY = std::numeric_limits<double>::max();
|
double minimumY = std::numeric_limits<double>::max();
|
||||||
double maximumY = std::numeric_limits<double>::min();
|
double maximumY = std::numeric_limits<double>::min();
|
||||||
@@ -478,7 +478,7 @@ static QLineF mergedVerticalLine(const QList<QLineF> &lineList)
|
|||||||
maximumY = qMax(maximumY, double(line.y2()));
|
maximumY = qMax(maximumY, double(line.y2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
double x(lineList.first().x1());
|
double x(lineList.constFirst().x1());
|
||||||
return QLineF(x, minimumY, x, maximumY);
|
return QLineF(x, minimumY, x, maximumY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -450,7 +450,7 @@ void DesignDocument::paste()
|
|||||||
ModelNode targetNode;
|
ModelNode targetNode;
|
||||||
|
|
||||||
if (!view.selectedModelNodes().isEmpty())
|
if (!view.selectedModelNodes().isEmpty())
|
||||||
targetNode = view.selectedModelNodes().first();
|
targetNode = view.selectedModelNodes().constFirst();
|
||||||
|
|
||||||
//In case we copy and paste a selection we paste in the parent item
|
//In case we copy and paste a selection we paste in the parent item
|
||||||
if ((view.selectedModelNodes().count() == selectedNodes.count()) && targetNode.isValid() && targetNode.hasParentProperty())
|
if ((view.selectedModelNodes().count() == selectedNodes.count()) && targetNode.isValid() && targetNode.hasParentProperty())
|
||||||
@@ -495,7 +495,7 @@ void DesignDocument::paste()
|
|||||||
ModelNode targetNode;
|
ModelNode targetNode;
|
||||||
|
|
||||||
if (!view.selectedModelNodes().isEmpty())
|
if (!view.selectedModelNodes().isEmpty())
|
||||||
targetNode = view.selectedModelNodes().first();
|
targetNode = view.selectedModelNodes().constFirst();
|
||||||
|
|
||||||
if (!targetNode.isValid())
|
if (!targetNode.isValid())
|
||||||
targetNode = view.rootModelNode();
|
targetNode = view.rootModelNode();
|
||||||
|
@@ -219,7 +219,7 @@ void DesignDocumentView::copyModelNodes(const QList<ModelNode> &nodesToCopy)
|
|||||||
copyModel->attachView(&view);
|
copyModel->attachView(&view);
|
||||||
|
|
||||||
if (selectedNodes.count() == 1) {
|
if (selectedNodes.count() == 1) {
|
||||||
ModelNode selectedNode(selectedNodes.first());
|
const ModelNode &selectedNode = selectedNodes.constFirst();
|
||||||
|
|
||||||
if (!selectedNode.isValid())
|
if (!selectedNode.isValid())
|
||||||
return;
|
return;
|
||||||
|
@@ -454,7 +454,7 @@ void NavigatorView::updateItemSelection()
|
|||||||
blockSelectionChangedSignal(blocked);
|
blockSelectionChangedSignal(blocked);
|
||||||
|
|
||||||
if (!selectedModelNodes().isEmpty())
|
if (!selectedModelNodes().isEmpty())
|
||||||
treeWidget()->scrollTo(indexForModelNode(selectedModelNodes().first()));
|
treeWidget()->scrollTo(indexForModelNode(selectedModelNodes().constFirst()));
|
||||||
|
|
||||||
// make sure selected nodes a visible
|
// make sure selected nodes a visible
|
||||||
foreach (const QModelIndex &selectedIndex, itemSelection.indexes()) {
|
foreach (const QModelIndex &selectedIndex, itemSelection.indexes()) {
|
||||||
|
@@ -145,7 +145,7 @@ void PropertyEditorContextObject::toogleExportAlias()
|
|||||||
if (rewriterView->selectedModelNodes().isEmpty())
|
if (rewriterView->selectedModelNodes().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ModelNode selectedNode = rewriterView->selectedModelNodes().first();
|
const ModelNode &selectedNode = rewriterView->selectedModelNodes().constFirst();
|
||||||
|
|
||||||
if (QmlObjectNode::isValidQmlObjectNode(selectedNode)) {
|
if (QmlObjectNode::isValidQmlObjectNode(selectedNode)) {
|
||||||
QmlObjectNode objectNode(selectedNode);
|
QmlObjectNode objectNode(selectedNode);
|
||||||
@@ -184,7 +184,7 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
|
|||||||
if (rewriterView->selectedModelNodes().isEmpty())
|
if (rewriterView->selectedModelNodes().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ModelNode selectedNode = rewriterView->selectedModelNodes().first();
|
ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RewriterTransaction transaction =
|
RewriterTransaction transaction =
|
||||||
|
@@ -550,12 +550,12 @@ QString PropertyEditorQmlBackend::locateQmlFile(const NodeMetaInfo &info, const
|
|||||||
|
|
||||||
//Check for qml files with versions first
|
//Check for qml files with versions first
|
||||||
|
|
||||||
const QString withoutDir = relativePath.split(QStringLiteral("/")).last();
|
const QString withoutDir = relativePath.split(QStringLiteral("/")).constLast();
|
||||||
|
|
||||||
if (importDirVersion.exists(withoutDir))
|
if (importDirVersion.exists(withoutDir))
|
||||||
return importDirVersion.absoluteFilePath(withoutDir);
|
return importDirVersion.absoluteFilePath(withoutDir);
|
||||||
|
|
||||||
const QString withoutDirWithVersion = relativePathWithVersion.split(QStringLiteral("/")).last();
|
const QString withoutDirWithVersion = relativePathWithVersion.split(QStringLiteral("/")).constLast();
|
||||||
|
|
||||||
const QStringList possiblePaths = {
|
const QStringList possiblePaths = {
|
||||||
importDir.absoluteFilePath(relativePathWithVersion),
|
importDir.absoluteFilePath(relativePathWithVersion),
|
||||||
|
@@ -510,8 +510,8 @@ void PropertyEditorView::selectedNodesChanged(const QList<ModelNode> &selectedNo
|
|||||||
|
|
||||||
if (selectedNodeList.isEmpty() || selectedNodeList.count() > 1)
|
if (selectedNodeList.isEmpty() || selectedNodeList.count() > 1)
|
||||||
select(ModelNode());
|
select(ModelNode());
|
||||||
else if (m_selectedNode != selectedNodeList.first())
|
else if (m_selectedNode != selectedNodeList.constFirst())
|
||||||
select(selectedNodeList.first());
|
select(selectedNodeList.constFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
void PropertyEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
||||||
|
@@ -43,7 +43,7 @@ QImage StatesEditorImageProvider::requestImage(const QString &id, QSize *size, c
|
|||||||
|
|
||||||
bool nodeInstanceViewIsDetached = m_nodeInstanceView.isNull() || !m_nodeInstanceView->model();
|
bool nodeInstanceViewIsDetached = m_nodeInstanceView.isNull() || !m_nodeInstanceView->model();
|
||||||
if (!nodeInstanceViewIsDetached) {
|
if (!nodeInstanceViewIsDetached) {
|
||||||
QString imageId = id.split(QLatin1Char('-')).first();
|
QString imageId = id.split(QLatin1Char('-')).constFirst();
|
||||||
if (imageId == QLatin1String("baseState")) {
|
if (imageId == QLatin1String("baseState")) {
|
||||||
image = m_nodeInstanceView->statePreviewImage(m_nodeInstanceView->rootModelNode());
|
image = m_nodeInstanceView->statePreviewImage(m_nodeInstanceView->rootModelNode());
|
||||||
} else {
|
} else {
|
||||||
|
@@ -186,7 +186,7 @@ void TextEditorView::documentMessagesChanged(const QList<DocumentMessage> &error
|
|||||||
if (errors.isEmpty()) {
|
if (errors.isEmpty()) {
|
||||||
m_widget->clearStatusBar();
|
m_widget->clearStatusBar();
|
||||||
} else {
|
} else {
|
||||||
const DocumentMessage error = errors.first();
|
const DocumentMessage &error = errors.constFirst();
|
||||||
m_widget->setStatusText(QString("%1 (Line: %2)").arg(error.description()).arg(error.line()));
|
m_widget->setStatusText(QString("%1 (Line: %2)").arg(error.description()).arg(error.line()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -126,7 +126,7 @@ void TextEditorWidget::jumpTextCursorToSelectedModelNode()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_textEditorView->selectedModelNodes().isEmpty())
|
if (!m_textEditorView->selectedModelNodes().isEmpty())
|
||||||
selectedNode = m_textEditorView->selectedModelNodes().first();
|
selectedNode = m_textEditorView->selectedModelNodes().constFirst();
|
||||||
|
|
||||||
if (selectedNode.isValid()) {
|
if (selectedNode.isValid()) {
|
||||||
RewriterView *rewriterView = m_textEditorView->model()->rewriterView();
|
RewriterView *rewriterView = m_textEditorView->model()->rewriterView();
|
||||||
|
@@ -66,7 +66,7 @@ bool QmlRefactoring::reparseDocument()
|
|||||||
qDebug() << "*** QML text:" << textModifier->text();
|
qDebug() << "*** QML text:" << textModifier->text();
|
||||||
QString errorMessage = QStringLiteral("Parsing Error");
|
QString errorMessage = QStringLiteral("Parsing Error");
|
||||||
if (!tmpDocument->diagnosticMessages().isEmpty())
|
if (!tmpDocument->diagnosticMessages().isEmpty())
|
||||||
errorMessage = tmpDocument->diagnosticMessages().first().message;
|
errorMessage = tmpDocument->diagnosticMessages().constFirst().message;
|
||||||
|
|
||||||
qDebug() << "*** " << errorMessage;
|
qDebug() << "*** " << errorMessage;
|
||||||
return false;
|
return false;
|
||||||
|
@@ -280,7 +280,7 @@ ViewType *ForwardView<ViewType>::firstView() const
|
|||||||
if (m_targetViewList.isEmpty())
|
if (m_targetViewList.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return m_targetViewList.first().data();
|
return m_targetViewList.constFirst().data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -881,8 +881,8 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
|
|||||||
|
|
||||||
if (versionString.contains(QStringLiteral("."))) {
|
if (versionString.contains(QStringLiteral("."))) {
|
||||||
const QStringList splittedString = versionString.split(QStringLiteral("."));
|
const QStringList splittedString = versionString.split(QStringLiteral("."));
|
||||||
majorVersion = splittedString.first().toInt();
|
majorVersion = splittedString.constFirst().toInt();
|
||||||
minorVersion = splittedString.last().toInt();
|
minorVersion = splittedString.constLast().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isItem = false;
|
bool isItem = false;
|
||||||
|
@@ -278,9 +278,9 @@ void MetaInfoReader::setVersion(const QString &versionNumber)
|
|||||||
int val;
|
int val;
|
||||||
bool ok;
|
bool ok;
|
||||||
if (versionNumber.contains(QLatin1Char('.'))) {
|
if (versionNumber.contains(QLatin1Char('.'))) {
|
||||||
val = versionNumber.split(QLatin1Char('.')).first().toInt(&ok);
|
val = versionNumber.split(QLatin1Char('.')).constFirst().toInt(&ok);
|
||||||
major = ok ? val : major;
|
major = ok ? val : major;
|
||||||
val = versionNumber.split(QLatin1Char('.')).last().toInt(&ok);
|
val = versionNumber.split(QLatin1Char('.')).constLast().toInt(&ok);
|
||||||
minor = ok ? val : minor;
|
minor = ok ? val : minor;
|
||||||
} else {
|
} else {
|
||||||
val = versionNumber.toInt(&ok);
|
val = versionNumber.toInt(&ok);
|
||||||
|
@@ -96,7 +96,7 @@ QmlDesigner::NodeHints::NodeHints(const ModelNode &node) : m_modelNode(node)
|
|||||||
modelNode().type(), modelNode().majorVersion(), modelNode().minorVersion());
|
modelNode().type(), modelNode().majorVersion(), modelNode().minorVersion());
|
||||||
|
|
||||||
if (!itemLibraryEntryList.isEmpty())
|
if (!itemLibraryEntryList.isEmpty())
|
||||||
m_hints = itemLibraryEntryList.first().hints();
|
m_hints = itemLibraryEntryList.constFirst().hints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -709,7 +709,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i
|
|||||||
} else {
|
} else {
|
||||||
m_isFileComponent = true;
|
m_isFileComponent = true;
|
||||||
const Imports *imports = context()->imports(document());
|
const Imports *imports = context()->imports(document());
|
||||||
ImportInfo importInfo = imports->info(lookupNameComponent().last(), context().data());
|
ImportInfo importInfo = imports->info(lookupNameComponent().constLast(), context().data());
|
||||||
if (importInfo.isValid() && importInfo.type() == ImportType::Library) {
|
if (importInfo.isValid() && importInfo.type() == ImportType::Library) {
|
||||||
m_majorVersion = importInfo.version().majorVersion();
|
m_majorVersion = importInfo.version().majorVersion();
|
||||||
m_minorVersion = importInfo.version().minorVersion();
|
m_minorVersion = importInfo.version().minorVersion();
|
||||||
@@ -729,7 +729,7 @@ const CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const
|
|||||||
const QList<TypeName> nameComponents = m_qualfiedTypeName.split('.');
|
const QList<TypeName> nameComponents = m_qualfiedTypeName.split('.');
|
||||||
if (nameComponents.size() < 2)
|
if (nameComponents.size() < 2)
|
||||||
return 0;
|
return 0;
|
||||||
const TypeName type = nameComponents.last();
|
const TypeName &type = nameComponents.constLast();
|
||||||
|
|
||||||
TypeName module;
|
TypeName module;
|
||||||
for (int i = 0; i < nameComponents.size() - 1; ++i) {
|
for (int i = 0; i < nameComponents.size() - 1; ++i) {
|
||||||
@@ -821,8 +821,8 @@ bool NodeMetaInfoPrivate::isPropertyWritable(const PropertyName &propertyName) c
|
|||||||
|
|
||||||
if (propertyName.contains('.')) {
|
if (propertyName.contains('.')) {
|
||||||
const PropertyNameList parts = propertyName.split('.');
|
const PropertyNameList parts = propertyName.split('.');
|
||||||
const PropertyName objectName = parts.first();
|
const PropertyName &objectName = parts.constFirst();
|
||||||
const PropertyName rawPropertyName = parts.last();
|
const PropertyName &rawPropertyName = parts.constLast();
|
||||||
const TypeName objectType = propertyType(objectName);
|
const TypeName objectType = propertyType(objectName);
|
||||||
|
|
||||||
if (isValueType(objectType))
|
if (isValueType(objectType))
|
||||||
@@ -854,8 +854,8 @@ bool NodeMetaInfoPrivate::isPropertyList(const PropertyName &propertyName) const
|
|||||||
|
|
||||||
if (propertyName.contains('.')) {
|
if (propertyName.contains('.')) {
|
||||||
const PropertyNameList parts = propertyName.split('.');
|
const PropertyNameList parts = propertyName.split('.');
|
||||||
const PropertyName objectName = parts.first();
|
const PropertyName &objectName = parts.constFirst();
|
||||||
const PropertyName rawPropertyName = parts.last();
|
const PropertyName &rawPropertyName = parts.constLast();
|
||||||
const TypeName objectType = propertyType(objectName);
|
const TypeName objectType = propertyType(objectName);
|
||||||
|
|
||||||
if (isValueType(objectType))
|
if (isValueType(objectType))
|
||||||
@@ -883,8 +883,8 @@ bool NodeMetaInfoPrivate::isPropertyPointer(const PropertyName &propertyName) co
|
|||||||
|
|
||||||
if (propertyName.contains('.')) {
|
if (propertyName.contains('.')) {
|
||||||
const PropertyNameList parts = propertyName.split('.');
|
const PropertyNameList parts = propertyName.split('.');
|
||||||
const PropertyName objectName = parts.first();
|
const PropertyName &objectName = parts.constFirst();
|
||||||
const PropertyName rawPropertyName = parts.last();
|
const PropertyName &rawPropertyName = parts.constLast();
|
||||||
const TypeName objectType = propertyType(objectName);
|
const TypeName objectType = propertyType(objectName);
|
||||||
|
|
||||||
if (isValueType(objectType))
|
if (isValueType(objectType))
|
||||||
@@ -915,8 +915,8 @@ bool NodeMetaInfoPrivate::isPropertyEnum(const PropertyName &propertyName) const
|
|||||||
|
|
||||||
if (propertyName.contains('.')) {
|
if (propertyName.contains('.')) {
|
||||||
const PropertyNameList parts = propertyName.split('.');
|
const PropertyNameList parts = propertyName.split('.');
|
||||||
const PropertyName objectName = parts.first();
|
const PropertyName &objectName = parts.constFirst();
|
||||||
const PropertyName rawPropertyName = parts.last();
|
const PropertyName &rawPropertyName = parts.constLast();
|
||||||
const TypeName objectType = propertyType(objectName);
|
const TypeName objectType = propertyType(objectName);
|
||||||
|
|
||||||
if (isValueType(objectType))
|
if (isValueType(objectType))
|
||||||
@@ -947,8 +947,8 @@ QString NodeMetaInfoPrivate::propertyEnumScope(const PropertyName &propertyName)
|
|||||||
|
|
||||||
if (propertyName.contains('.')) {
|
if (propertyName.contains('.')) {
|
||||||
const PropertyNameList parts = propertyName.split('.');
|
const PropertyNameList parts = propertyName.split('.');
|
||||||
const PropertyName objectName = parts.first();
|
const PropertyName &objectName = parts.constFirst();
|
||||||
const PropertyName rawPropertyName = parts.last();
|
const PropertyName &rawPropertyName = parts.constLast();
|
||||||
const TypeName objectType = propertyType(objectName);
|
const TypeName objectType = propertyType(objectName);
|
||||||
|
|
||||||
if (isValueType(objectType))
|
if (isValueType(objectType))
|
||||||
@@ -989,7 +989,7 @@ static QByteArray getUnqualifiedName(const QByteArray &name)
|
|||||||
const QList<QByteArray> nameComponents = name.split('.');
|
const QList<QByteArray> nameComponents = name.split('.');
|
||||||
if (nameComponents.size() < 2)
|
if (nameComponents.size() < 2)
|
||||||
return name;
|
return name;
|
||||||
return nameComponents.last();
|
return nameComponents.constLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QByteArray getPackage(const QByteArray &name)
|
static QByteArray getPackage(const QByteArray &name)
|
||||||
@@ -1138,7 +1138,7 @@ QString NodeMetaInfoPrivate::importDirectoryPath() const
|
|||||||
|
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
const Imports *imports = context()->imports(document());
|
const Imports *imports = context()->imports(document());
|
||||||
ImportInfo importInfo = imports->info(lookupNameComponent().last(), context().data());
|
ImportInfo importInfo = imports->info(lookupNameComponent().constLast(), context().data());
|
||||||
|
|
||||||
if (importInfo.type() == ImportType::Directory) {
|
if (importInfo.type() == ImportType::Directory) {
|
||||||
return importInfo.path();
|
return importInfo.path();
|
||||||
|
@@ -152,7 +152,7 @@ void SubComponentManager::parseDirectories()
|
|||||||
parseDirectory(dirInfo.canonicalFilePath(), false);
|
parseDirectory(dirInfo.canonicalFilePath(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fullUrlVersion = path + QLatin1Char('/') + url + QLatin1Char('.') + import.version().split(".").first();
|
QString fullUrlVersion = path + QLatin1Char('/') + url + QLatin1Char('.') + import.version().split(".").constFirst();
|
||||||
dirInfo = QFileInfo(fullUrlVersion);
|
dirInfo = QFileInfo(fullUrlVersion);
|
||||||
|
|
||||||
if (dirInfo.exists() && dirInfo.isDir()) {
|
if (dirInfo.exists() && dirInfo.isDir()) {
|
||||||
|
@@ -437,7 +437,7 @@ QList<ModelNode> AbstractView::selectedModelNodes() const
|
|||||||
ModelNode AbstractView::firstSelectedModelNode() const
|
ModelNode AbstractView::firstSelectedModelNode() const
|
||||||
{
|
{
|
||||||
if (hasSelectedModelNodes())
|
if (hasSelectedModelNodes())
|
||||||
return ModelNode(model()->d->selectedNodes().first(), model(), this);
|
return ModelNode(model()->d->selectedNodes().constFirst(), model(), this);
|
||||||
|
|
||||||
return ModelNode();
|
return ModelNode();
|
||||||
}
|
}
|
||||||
@@ -445,7 +445,7 @@ ModelNode AbstractView::firstSelectedModelNode() const
|
|||||||
ModelNode AbstractView::singleSelectedModelNode() const
|
ModelNode AbstractView::singleSelectedModelNode() const
|
||||||
{
|
{
|
||||||
if (hasSingleSelectedModelNode())
|
if (hasSingleSelectedModelNode())
|
||||||
return ModelNode(model()->d->selectedNodes().first(), model(), this);
|
return ModelNode(model()->d->selectedNodes().constFirst(), model(), this);
|
||||||
|
|
||||||
return ModelNode();
|
return ModelNode();
|
||||||
}
|
}
|
||||||
@@ -725,7 +725,7 @@ static int getMinorVersionFromImport(const Model *model)
|
|||||||
if (import.isLibraryImport() && import.url() == "QtQuick") {
|
if (import.isLibraryImport() && import.url() == "QtQuick") {
|
||||||
const QString versionString = import.version();
|
const QString versionString = import.version();
|
||||||
if (versionString.contains(".")) {
|
if (versionString.contains(".")) {
|
||||||
const QString minorVersionString = versionString.split(".").last();
|
const QString minorVersionString = versionString.split(".").constLast();
|
||||||
return minorVersionString.toInt();
|
return minorVersionString.toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -740,7 +740,7 @@ static int getMajorVersionFromImport(const Model *model)
|
|||||||
if (import.isLibraryImport() && import.url() == QStringLiteral("QtQuick")) {
|
if (import.isLibraryImport() && import.url() == QStringLiteral("QtQuick")) {
|
||||||
const QString versionString = import.version();
|
const QString versionString = import.version();
|
||||||
if (versionString.contains(QStringLiteral("."))) {
|
if (versionString.contains(QStringLiteral("."))) {
|
||||||
const QString majorVersionString = versionString.split(QStringLiteral(".")).first();
|
const QString majorVersionString = versionString.split(QStringLiteral(".")).constFirst();
|
||||||
return majorVersionString.toInt();
|
return majorVersionString.toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -161,7 +161,7 @@ AbstractProperty BindingProperty::resolveToProperty() const
|
|||||||
ModelNode node = parentModelNode();
|
ModelNode node = parentModelNode();
|
||||||
QString element;
|
QString element;
|
||||||
if (binding.contains(QLatin1Char('.'))) {
|
if (binding.contains(QLatin1Char('.'))) {
|
||||||
element = binding.split(QLatin1Char('.')).last();
|
element = binding.split(QLatin1Char('.')).constLast();
|
||||||
QString nodeBinding = binding;
|
QString nodeBinding = binding;
|
||||||
nodeBinding.chop(element.length());
|
nodeBinding.chop(element.length());
|
||||||
node = resolveBinding(nodeBinding, parentModelNode(), view());
|
node = resolveBinding(nodeBinding, parentModelNode(), view());
|
||||||
|
@@ -1882,17 +1882,17 @@ static bool compareVersions(const QString &version1, const QString &version2, bo
|
|||||||
QStringList version2List = version2.split(QLatin1Char('.'));
|
QStringList version2List = version2.split(QLatin1Char('.'));
|
||||||
if (version1List.count() == 2 && version2List.count() == 2) {
|
if (version1List.count() == 2 && version2List.count() == 2) {
|
||||||
bool ok;
|
bool ok;
|
||||||
int major1 = version1List.first().toInt(&ok);
|
int major1 = version1List.constFirst().toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return false;
|
return false;
|
||||||
int major2 = version2List.first().toInt(&ok);
|
int major2 = version2List.constFirst().toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return false;
|
return false;
|
||||||
if (major1 >= major2) {
|
if (major1 >= major2) {
|
||||||
int minor1 = version1List.last().toInt(&ok);
|
int minor1 = version1List.constLast().toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return false;
|
return false;
|
||||||
int minor2 = version2List.last().toInt(&ok);
|
int minor2 = version2List.constLast().toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return false;
|
return false;
|
||||||
if (minor1 >= minor2)
|
if (minor1 >= minor2)
|
||||||
|
@@ -310,7 +310,7 @@ QString ModelNode::simplifiedTypeName() const
|
|||||||
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
|
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString::fromUtf8(type().split('.').last());
|
return QString::fromUtf8(type().split('.').constLast());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ModelNode::displayName() const
|
QString ModelNode::displayName() const
|
||||||
@@ -1138,7 +1138,7 @@ bool ModelNode::isComponent() const
|
|||||||
* the default property is always implcitly a NodeListProperty. This is something that has to be fixed.
|
* the default property is always implcitly a NodeListProperty. This is something that has to be fixed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ModelNode componentNode = nodeListProperty("component").toModelNodeList().first();
|
ModelNode componentNode = nodeListProperty("component").toModelNodeList().constFirst();
|
||||||
if (componentNode.nodeSourceType() == ModelNode::NodeWithComponentSource)
|
if (componentNode.nodeSourceType() == ModelNode::NodeWithComponentSource)
|
||||||
return true;
|
return true;
|
||||||
if (componentNode.metaInfo().isFileComponent())
|
if (componentNode.metaInfo().isFileComponent())
|
||||||
@@ -1175,7 +1175,7 @@ QIcon ModelNode::typeIcon() const
|
|||||||
QList <ItemLibraryEntry> itemLibraryEntryList = libraryInfo->entriesForType(
|
QList <ItemLibraryEntry> itemLibraryEntryList = libraryInfo->entriesForType(
|
||||||
type(), majorVersion(), minorVersion());
|
type(), majorVersion(), minorVersion());
|
||||||
if (!itemLibraryEntryList.isEmpty())
|
if (!itemLibraryEntryList.isEmpty())
|
||||||
return itemLibraryEntryList.first().typeIcon();
|
return itemLibraryEntryList.constFirst().typeIcon();
|
||||||
else if (metaInfo().isValid())
|
else if (metaInfo().isValid())
|
||||||
return QIcon(QStringLiteral(":/ItemLibrary/images/item-default-icon.png"));
|
return QIcon(QStringLiteral(":/ItemLibrary/images/item-default-icon.png"));
|
||||||
}
|
}
|
||||||
|
@@ -229,7 +229,7 @@ void ModelToTextMerger::applyChanges()
|
|||||||
|
|
||||||
QString errorMessage = QStringLiteral("Error while rewriting");
|
QString errorMessage = QStringLiteral("Error while rewriting");
|
||||||
if (!tmpDocument->diagnosticMessages().isEmpty())
|
if (!tmpDocument->diagnosticMessages().isEmpty())
|
||||||
errorMessage = tmpDocument->diagnosticMessages().first().message;
|
errorMessage = tmpDocument->diagnosticMessages().constFirst().message;
|
||||||
|
|
||||||
m_rewriterView->enterErrorState(errorMessage);
|
m_rewriterView->enterErrorState(errorMessage);
|
||||||
return;
|
return;
|
||||||
|
@@ -167,8 +167,8 @@ QString QmlTextGenerator::toQml(const ModelNode &node, int indentDepth) const
|
|||||||
QString url;
|
QString url;
|
||||||
if (type.contains('.')) {
|
if (type.contains('.')) {
|
||||||
QStringList nameComponents = type.split('.');
|
QStringList nameComponents = type.split('.');
|
||||||
url = nameComponents.first();
|
url = nameComponents.constFirst();
|
||||||
type = nameComponents.last();
|
type = nameComponents.constLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString alias;
|
QString alias;
|
||||||
|
@@ -402,7 +402,7 @@ void RewriterView::applyChanges()
|
|||||||
try {
|
try {
|
||||||
modelToTextMerger()->applyChanges();
|
modelToTextMerger()->applyChanges();
|
||||||
if (!errors().isEmpty())
|
if (!errors().isEmpty())
|
||||||
enterErrorState(errors().first().description());
|
enterErrorState(errors().constFirst().description());
|
||||||
} catch (const Exception &e) {
|
} catch (const Exception &e) {
|
||||||
const QString content = textModifierContent();
|
const QString content = textModifierContent();
|
||||||
qDebug().noquote() << "RewriterException:" << m_rewritingErrorMessage;
|
qDebug().noquote() << "RewriterException:" << m_rewritingErrorMessage;
|
||||||
@@ -417,7 +417,7 @@ void RewriterView::applyChanges()
|
|||||||
qDebug().noquote() << "RewriterException: " << m_rewritingErrorMessage;
|
qDebug().noquote() << "RewriterException: " << m_rewritingErrorMessage;
|
||||||
qDebug().noquote() << "Content: " << content;
|
qDebug().noquote() << "Content: " << content;
|
||||||
if (!errors().isEmpty())
|
if (!errors().isEmpty())
|
||||||
qDebug().noquote() << "Error:" << errors().first().description();
|
qDebug().noquote() << "Error:" << errors().constFirst().description();
|
||||||
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, qPrintable(m_rewritingErrorMessage), content);
|
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, qPrintable(m_rewritingErrorMessage), content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -668,7 +668,7 @@ QString RewriterView::convertTypeToImportAlias(const QString &type) const
|
|||||||
if (type.contains('.')) {
|
if (type.contains('.')) {
|
||||||
QStringList nameComponents = type.split('.');
|
QStringList nameComponents = type.split('.');
|
||||||
url = getUrlFromType(type);
|
url = getUrlFromType(type);
|
||||||
simplifiedType = nameComponents.last();
|
simplifiedType = nameComponents.constLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString alias;
|
QString alias;
|
||||||
|
@@ -166,7 +166,7 @@ static inline bool isSignalPropertyName(const QString &signalName)
|
|||||||
// see QmlCompiler::isSignalPropertyName
|
// see QmlCompiler::isSignalPropertyName
|
||||||
QStringList list = signalName.split(QLatin1String("."));
|
QStringList list = signalName.split(QLatin1String("."));
|
||||||
|
|
||||||
QString pureSignalName = list.last();
|
const QString &pureSignalName = list.constLast();
|
||||||
return pureSignalName.length() >= 3 && pureSignalName.startsWith(QStringLiteral("on")) &&
|
return pureSignalName.length() >= 3 && pureSignalName.startsWith(QStringLiteral("on")) &&
|
||||||
pureSignalName.at(2).isLetter();
|
pureSignalName.at(2).isLetter();
|
||||||
}
|
}
|
||||||
@@ -611,12 +611,12 @@ public:
|
|||||||
|
|
||||||
if (astValueList.count() == 2) {
|
if (astValueList.count() == 2) {
|
||||||
//Check for global Qt enums
|
//Check for global Qt enums
|
||||||
if (astValueList.first() == QStringLiteral("Qt")
|
if (astValueList.constFirst() == QStringLiteral("Qt")
|
||||||
&& globalQtEnums().contains(astValueList.last()))
|
&& globalQtEnums().contains(astValueList.constLast()))
|
||||||
return QVariant::fromValue(Enumeration(astValue));
|
return QVariant::fromValue(Enumeration(astValue));
|
||||||
|
|
||||||
//Check for known enum scopes used globally
|
//Check for known enum scopes used globally
|
||||||
if (knownEnumScopes().contains(astValueList.first()))
|
if (knownEnumScopes().contains(astValueList.constFirst()))
|
||||||
return QVariant::fromValue(Enumeration(astValue));
|
return QVariant::fromValue(Enumeration(astValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,7 +640,7 @@ public:
|
|||||||
QString rhsValueName;
|
QString rhsValueName;
|
||||||
if (AST::IdentifierExpression *idExp = AST::cast<AST::IdentifierExpression *>(eStmt->expression)) {
|
if (AST::IdentifierExpression *idExp = AST::cast<AST::IdentifierExpression *>(eStmt->expression)) {
|
||||||
if (!m_scopeChain.qmlScopeObjects().isEmpty())
|
if (!m_scopeChain.qmlScopeObjects().isEmpty())
|
||||||
rhsValueObject = m_scopeChain.qmlScopeObjects().last();
|
rhsValueObject = m_scopeChain.qmlScopeObjects().constLast();
|
||||||
if (!idExp->name.isEmpty())
|
if (!idExp->name.isEmpty())
|
||||||
rhsValueName = idExp->name.toString();
|
rhsValueName = idExp->name.toString();
|
||||||
} else if (AST::FieldMemberExpression *memberExp = AST::cast<AST::FieldMemberExpression *>(eStmt->expression)) {
|
} else if (AST::FieldMemberExpression *memberExp = AST::cast<AST::FieldMemberExpression *>(eStmt->expression)) {
|
||||||
@@ -792,8 +792,8 @@ static bool isLatestImportVersion(const ImportKey &importKey, const QHash<QStrin
|
|||||||
|
|
||||||
static bool isBlacklistImport(const ImportKey &importKey)
|
static bool isBlacklistImport(const ImportKey &importKey)
|
||||||
{
|
{
|
||||||
QString importPathFirst = importKey.splitPath.first();
|
const QString &importPathFirst = importKey.splitPath.constFirst();
|
||||||
QString importPathLast = importKey.splitPath.last();
|
const QString &importPathLast = importKey.splitPath.constLast();
|
||||||
return importPathFirst == QStringLiteral("<cpp>")
|
return importPathFirst == QStringLiteral("<cpp>")
|
||||||
|| importPathFirst == QStringLiteral("QML")
|
|| importPathFirst == QStringLiteral("QML")
|
||||||
|| importPathFirst == QStringLiteral("QtQml")
|
|| importPathFirst == QStringLiteral("QtQml")
|
||||||
@@ -1439,7 +1439,7 @@ static QString fileForFullQrcPath(const QString &string)
|
|||||||
if (stringList.isEmpty())
|
if (stringList.isEmpty())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
return stringList.last();
|
return stringList.constLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString removeFileFromQrcPath(const QString &string)
|
static QString removeFileFromQrcPath(const QString &string)
|
||||||
@@ -2046,7 +2046,7 @@ void TextToModelMerger::populateQrcMapping(const QString &filePath)
|
|||||||
QMap<QString,QStringList> map = ModelManagerInterface::instance()->filesInQrcPath(path);
|
QMap<QString,QStringList> map = ModelManagerInterface::instance()->filesInQrcPath(path);
|
||||||
const QStringList qrcFilePaths = map.value(fileName, {});
|
const QStringList qrcFilePaths = map.value(fileName, {});
|
||||||
if (!qrcFilePaths.isEmpty()) {
|
if (!qrcFilePaths.isEmpty()) {
|
||||||
QString fileSystemPath = qrcFilePaths.first();
|
QString fileSystemPath = qrcFilePaths.constFirst();
|
||||||
fileSystemPath.remove(fileName);
|
fileSystemPath.remove(fileName);
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
path.prepend(QLatin1String("/"));
|
path.prepend(QLatin1String("/"));
|
||||||
|
@@ -441,7 +441,7 @@ static QWidget *createbottomSideBarWidget(const QList<WidgetInfo> &widgetInfos)
|
|||||||
topWidgetInfos.append(widgetInfo);
|
topWidgetInfos.append(widgetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *widget = topWidgetInfos.first().widget;
|
QWidget *widget = topWidgetInfos.constFirst().widget;
|
||||||
if (topWidgetInfos.count() > 1) {
|
if (topWidgetInfos.count() > 1) {
|
||||||
QWidget *background = new QWidget();
|
QWidget *background = new QWidget();
|
||||||
background->setProperty("designerBackgroundColor", true);
|
background->setProperty("designerBackgroundColor", true);
|
||||||
|
@@ -138,7 +138,7 @@ static void openComponentSourcePropertyOfLoader(const ModelNode &modelNode)
|
|||||||
* the default property is always implcitly a NodeListProperty. This is something that has to be fixed.
|
* the default property is always implcitly a NodeListProperty. This is something that has to be fixed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
componentModelNode = modelNode.nodeListProperty("component").toModelNodeList().first();
|
componentModelNode = modelNode.nodeListProperty("component").toModelNodeList().constFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::EditorManager::openEditor(componentModelNode.metaInfo().componentFileName(), Core::Id(), Core::EditorManager::DoNotMakeVisible);
|
Core::EditorManager::openEditor(componentModelNode.metaInfo().componentFileName(), Core::Id(), Core::EditorManager::DoNotMakeVisible);
|
||||||
|
@@ -170,8 +170,8 @@ void ColorTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
|
|||||||
m_formEditorItem->qmlItemNode().setVariantProperty("color", m_oldColor);
|
m_formEditorItem->qmlItemNode().setVariantProperty("color", m_oldColor);
|
||||||
|
|
||||||
if (!itemList.isEmpty()
|
if (!itemList.isEmpty()
|
||||||
&& itemList.first()->qmlItemNode().modelNode().metaInfo().hasProperty("color")) {
|
&& itemList.constFirst()->qmlItemNode().modelNode().metaInfo().hasProperty("color")) {
|
||||||
m_formEditorItem = itemList.first();
|
m_formEditorItem = itemList.constFirst();
|
||||||
m_oldColor = m_formEditorItem->qmlItemNode().modelValue("color").value<QColor>();
|
m_oldColor = m_formEditorItem->qmlItemNode().modelValue("color").value<QColor>();
|
||||||
|
|
||||||
if (m_colorDialog.isNull()) {
|
if (m_colorDialog.isNull()) {
|
||||||
|
@@ -232,7 +232,7 @@ void BackendModel::addNewBackend()
|
|||||||
|
|
||||||
QString typeName = dialog.type();
|
QString typeName = dialog.type();
|
||||||
|
|
||||||
Import import = Import::createLibraryImport(importSplit.first(), importSplit.last());
|
Import import = Import::createLibraryImport(importSplit.constFirst(), importSplit.constLast());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@@ -160,7 +160,7 @@ QStringList BindingModel::possibleSourceProperties(const BindingProperty &bindin
|
|||||||
qWarning() << " BindingModel::possibleSourcePropertiesForRow no meta info for target node";
|
qWarning() << " BindingModel::possibleSourcePropertiesForRow no meta info for target node";
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString id = stringlist.first();
|
const QString &id = stringlist.constFirst();
|
||||||
|
|
||||||
ModelNode modelNode = getNodeByIdOrParent(id, bindingProperty.parentModelNode());
|
ModelNode modelNode = getNodeByIdOrParent(id, bindingProperty.parentModelNode());
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ static PropertyName unusedProperty(const ModelNode &modelNode)
|
|||||||
void BindingModel::addBindingForCurrentNode()
|
void BindingModel::addBindingForCurrentNode()
|
||||||
{
|
{
|
||||||
if (connectionView()->selectedModelNodes().count() == 1) {
|
if (connectionView()->selectedModelNodes().count() == 1) {
|
||||||
ModelNode modelNode = connectionView()->selectedModelNodes().first();
|
const ModelNode &modelNode = connectionView()->selectedModelNodes().constFirst();
|
||||||
if (modelNode.isValid()) {
|
if (modelNode.isValid()) {
|
||||||
try {
|
try {
|
||||||
modelNode.bindingProperty(unusedProperty(modelNode)).setExpression(QLatin1String("none.none"));
|
modelNode.bindingProperty(unusedProperty(modelNode)).setExpression(QLatin1String("none.none"));
|
||||||
@@ -386,7 +386,7 @@ bool BindingModel::getExpressionStrings(const BindingProperty &bindingProperty,
|
|||||||
if (true) {
|
if (true) {
|
||||||
const QStringList stringList = expression.split(QLatin1String("."));
|
const QStringList stringList = expression.split(QLatin1String("."));
|
||||||
|
|
||||||
*sourceNode = stringList.first();
|
*sourceNode = stringList.constFirst();
|
||||||
|
|
||||||
QString propertyName;
|
QString propertyName;
|
||||||
|
|
||||||
|
@@ -270,8 +270,8 @@ void ConnectionModel::addConnection()
|
|||||||
newNode.signalHandlerProperty("onClicked").setSource(QLatin1String("print(\"clicked\")"));
|
newNode.signalHandlerProperty("onClicked").setSource(QLatin1String("print(\"clicked\")"));
|
||||||
|
|
||||||
if (connectionView()->selectedModelNodes().count() == 1
|
if (connectionView()->selectedModelNodes().count() == 1
|
||||||
&& !connectionView()->selectedModelNodes().first().id().isEmpty()) {
|
&& !connectionView()->selectedModelNodes().constFirst().id().isEmpty()) {
|
||||||
ModelNode selectedNode = connectionView()->selectedModelNodes().first();
|
const ModelNode &selectedNode = connectionView()->selectedModelNodes().constFirst();
|
||||||
newNode.bindingProperty("target").setExpression(selectedNode.id());
|
newNode.bindingProperty("target").setExpression(selectedNode.id());
|
||||||
} else {
|
} else {
|
||||||
newNode.bindingProperty("target").setExpression(QLatin1String("parent"));
|
newNode.bindingProperty("target").setExpression(QLatin1String("parent"));
|
||||||
|
@@ -139,17 +139,17 @@ QList<QToolButton *> ConnectionViewWidget::createToolBarWidgets()
|
|||||||
QList<QToolButton *> buttons;
|
QList<QToolButton *> buttons;
|
||||||
|
|
||||||
buttons << new QToolButton();
|
buttons << new QToolButton();
|
||||||
buttons.last()->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
buttons.constLast()->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
||||||
buttons.last()->setToolTip(tr("Add binding or connection."));
|
buttons.constLast()->setToolTip(tr("Add binding or connection."));
|
||||||
connect(buttons.last(), &QAbstractButton::clicked, this, &ConnectionViewWidget::addButtonClicked);
|
connect(buttons.constLast(), &QAbstractButton::clicked, this, &ConnectionViewWidget::addButtonClicked);
|
||||||
connect(this, &ConnectionViewWidget::setEnabledAddButton, buttons.last(), &QWidget::setEnabled);
|
connect(this, &ConnectionViewWidget::setEnabledAddButton, buttons.constLast(), &QWidget::setEnabled);
|
||||||
|
|
||||||
buttons << new QToolButton();
|
buttons << new QToolButton();
|
||||||
buttons.last()->setIcon(Utils::Icons::MINUS.icon());
|
buttons.constLast()->setIcon(Utils::Icons::MINUS.icon());
|
||||||
buttons.last()->setToolTip(tr("Remove selected binding or connection."));
|
buttons.constLast()->setToolTip(tr("Remove selected binding or connection."));
|
||||||
buttons.last()->setShortcut(QKeySequence(Qt::Key_Delete));
|
buttons.constLast()->setShortcut(QKeySequence(Qt::Key_Delete));
|
||||||
connect(buttons.last(), &QAbstractButton::clicked, this, &ConnectionViewWidget::removeButtonClicked);
|
connect(buttons.constLast(), &QAbstractButton::clicked, this, &ConnectionViewWidget::removeButtonClicked);
|
||||||
connect(this, &ConnectionViewWidget::setEnabledRemoveButton, buttons.last(), &QWidget::setEnabled);
|
connect(this, &ConnectionViewWidget::setEnabledRemoveButton, buttons.constLast(), &QWidget::setEnabled);
|
||||||
|
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ void ConnectionViewWidget::removeButtonClicked()
|
|||||||
if (currentTab() == ConnectionTab) {
|
if (currentTab() == ConnectionTab) {
|
||||||
if (ui->connectionView->selectionModel()->selectedRows().isEmpty())
|
if (ui->connectionView->selectionModel()->selectedRows().isEmpty())
|
||||||
return;
|
return;
|
||||||
int currentRow = ui->connectionView->selectionModel()->selectedRows().first().row();
|
int currentRow = ui->connectionView->selectionModel()->selectedRows().constFirst().row();
|
||||||
ConnectionModel *connectionModel = qobject_cast<ConnectionModel*>(ui->connectionView->model());
|
ConnectionModel *connectionModel = qobject_cast<ConnectionModel*>(ui->connectionView->model());
|
||||||
if (connectionModel) {
|
if (connectionModel) {
|
||||||
connectionModel->deleteConnectionByRow(currentRow);
|
connectionModel->deleteConnectionByRow(currentRow);
|
||||||
@@ -241,7 +241,7 @@ void ConnectionViewWidget::removeButtonClicked()
|
|||||||
} else if (currentTab() == BindingTab) {
|
} else if (currentTab() == BindingTab) {
|
||||||
if (ui->bindingView->selectionModel()->selectedRows().isEmpty())
|
if (ui->bindingView->selectionModel()->selectedRows().isEmpty())
|
||||||
return;
|
return;
|
||||||
int currentRow = ui->bindingView->selectionModel()->selectedRows().first().row();
|
int currentRow = ui->bindingView->selectionModel()->selectedRows().constFirst().row();
|
||||||
BindingModel *bindingModel = qobject_cast<BindingModel*>(ui->bindingView->model());
|
BindingModel *bindingModel = qobject_cast<BindingModel*>(ui->bindingView->model());
|
||||||
if (bindingModel) {
|
if (bindingModel) {
|
||||||
bindingModel->deleteBindindByRow(currentRow);
|
bindingModel->deleteBindindByRow(currentRow);
|
||||||
@@ -249,12 +249,12 @@ void ConnectionViewWidget::removeButtonClicked()
|
|||||||
} else if (currentTab() == DynamicPropertiesTab) {
|
} else if (currentTab() == DynamicPropertiesTab) {
|
||||||
if (ui->dynamicPropertiesView->selectionModel()->selectedRows().isEmpty())
|
if (ui->dynamicPropertiesView->selectionModel()->selectedRows().isEmpty())
|
||||||
return;
|
return;
|
||||||
int currentRow = ui->dynamicPropertiesView->selectionModel()->selectedRows().first().row();
|
int currentRow = ui->dynamicPropertiesView->selectionModel()->selectedRows().constFirst().row();
|
||||||
DynamicPropertiesModel *dynamicPropertiesModel = qobject_cast<DynamicPropertiesModel*>(ui->dynamicPropertiesView->model());
|
DynamicPropertiesModel *dynamicPropertiesModel = qobject_cast<DynamicPropertiesModel*>(ui->dynamicPropertiesView->model());
|
||||||
if (dynamicPropertiesModel)
|
if (dynamicPropertiesModel)
|
||||||
dynamicPropertiesModel->deleteDynamicPropertyByRow(currentRow);
|
dynamicPropertiesModel->deleteDynamicPropertyByRow(currentRow);
|
||||||
} else if (currentTab() == BackendTab) {
|
} else if (currentTab() == BackendTab) {
|
||||||
int currentRow = ui->backendView->selectionModel()->selectedRows().first().row();
|
int currentRow = ui->backendView->selectionModel()->selectedRows().constFirst().row();
|
||||||
BackendModel *backendModel = qobject_cast<BackendModel*>(ui->backendView->model());
|
BackendModel *backendModel = qobject_cast<BackendModel*>(ui->backendView->model());
|
||||||
if (backendModel)
|
if (backendModel)
|
||||||
backendModel->deletePropertyByRow(currentRow);
|
backendModel->deletePropertyByRow(currentRow);
|
||||||
|
@@ -265,7 +265,7 @@ QStringList DynamicPropertiesModel::possibleTargetProperties(const BindingProper
|
|||||||
void DynamicPropertiesModel::addDynamicPropertyForCurrentNode()
|
void DynamicPropertiesModel::addDynamicPropertyForCurrentNode()
|
||||||
{
|
{
|
||||||
if (connectionView()->selectedModelNodes().count() == 1) {
|
if (connectionView()->selectedModelNodes().count() == 1) {
|
||||||
ModelNode modelNode = connectionView()->selectedModelNodes().first();
|
const ModelNode &modelNode = connectionView()->selectedModelNodes().constFirst();
|
||||||
if (modelNode.isValid()) {
|
if (modelNode.isValid()) {
|
||||||
try {
|
try {
|
||||||
modelNode.variantProperty(unusedProperty(modelNode)).setDynamicTypeNameAndValue("string", QLatin1String("none.none"));
|
modelNode.variantProperty(unusedProperty(modelNode)).setDynamicTypeNameAndValue("string", QLatin1String("none.none"));
|
||||||
@@ -292,7 +292,7 @@ QStringList DynamicPropertiesModel::possibleSourceProperties(const BindingProper
|
|||||||
qWarning() << " BindingModel::possibleSourcePropertiesForRow no meta info for target node";
|
qWarning() << " BindingModel::possibleSourcePropertiesForRow no meta info for target node";
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString id = stringlist.first();
|
const QString &id = stringlist.constFirst();
|
||||||
|
|
||||||
ModelNode modelNode = getNodeByIdOrParent(id, bindingProperty.parentModelNode());
|
ModelNode modelNode = getNodeByIdOrParent(id, bindingProperty.parentModelNode());
|
||||||
|
|
||||||
@@ -617,7 +617,7 @@ bool DynamicPropertiesModel::getExpressionStrings(const BindingProperty &binding
|
|||||||
if (true) {
|
if (true) {
|
||||||
const QStringList stringList = expression.split(QLatin1String("."));
|
const QStringList stringList = expression.split(QLatin1String("."));
|
||||||
|
|
||||||
*sourceNode = stringList.first();
|
*sourceNode = stringList.constFirst();
|
||||||
|
|
||||||
QString propertyName;
|
QString propertyName;
|
||||||
|
|
||||||
|
@@ -140,8 +140,8 @@ void PathItem::writePathToProperty()
|
|||||||
pathSegment.destroy();
|
pathSegment.destroy();
|
||||||
|
|
||||||
if (!m_cubicSegments.isEmpty()) {
|
if (!m_cubicSegments.isEmpty()) {
|
||||||
pathNode.variantProperty("startX").setValue(m_cubicSegments.first().firstControlPoint().coordinate().x());
|
pathNode.variantProperty("startX").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().x());
|
||||||
pathNode.variantProperty("startY").setValue(m_cubicSegments.first().firstControlPoint().coordinate().y());
|
pathNode.variantProperty("startY").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().y());
|
||||||
|
|
||||||
foreach (const CubicSegment &cubicSegment, m_cubicSegments) {
|
foreach (const CubicSegment &cubicSegment, m_cubicSegments) {
|
||||||
writePathAttributes(pathNode, cubicSegment.attributes());
|
writePathAttributes(pathNode, cubicSegment.attributes());
|
||||||
@@ -178,8 +178,8 @@ void PathItem::writePathAsCubicSegmentsOnly()
|
|||||||
pathSegment.destroy();
|
pathSegment.destroy();
|
||||||
|
|
||||||
if (!m_cubicSegments.isEmpty()) {
|
if (!m_cubicSegments.isEmpty()) {
|
||||||
pathNode.variantProperty("startX").setValue(m_cubicSegments.first().firstControlPoint().coordinate().x());
|
pathNode.variantProperty("startX").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().x());
|
||||||
pathNode.variantProperty("startY").setValue(m_cubicSegments.first().firstControlPoint().coordinate().y());
|
pathNode.variantProperty("startY").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().y());
|
||||||
|
|
||||||
|
|
||||||
foreach (const CubicSegment &cubicSegment, m_cubicSegments) {
|
foreach (const CubicSegment &cubicSegment, m_cubicSegments) {
|
||||||
@@ -239,7 +239,7 @@ static void drawCubicSegments(const QList<CubicSegment> &cubicSegments, QPainter
|
|||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
QPainterPath curvePainterPath(cubicSegments.first().firstControlPoint().coordinate());
|
QPainterPath curvePainterPath(cubicSegments.constFirst().firstControlPoint().coordinate());
|
||||||
|
|
||||||
foreach (const CubicSegment &cubicSegment, cubicSegments)
|
foreach (const CubicSegment &cubicSegment, cubicSegments)
|
||||||
addCubicSegmentToPainterPath(cubicSegment, curvePainterPath);
|
addCubicSegmentToPainterPath(cubicSegment, curvePainterPath);
|
||||||
@@ -547,9 +547,9 @@ void PathItem::readControlPoints()
|
|||||||
m_lastAttributes = actualAttributes;
|
m_lastAttributes = actualAttributes;
|
||||||
m_lastPercent = percent;
|
m_lastPercent = percent;
|
||||||
|
|
||||||
if (m_cubicSegments.first().firstControlPoint().coordinate() == m_cubicSegments.last().fourthControlPoint().coordinate()) {
|
if (m_cubicSegments.constFirst().firstControlPoint().coordinate() == m_cubicSegments.constLast().fourthControlPoint().coordinate()) {
|
||||||
CubicSegment lastCubicSegment = m_cubicSegments.last();
|
CubicSegment lastCubicSegment = m_cubicSegments.constLast();
|
||||||
lastCubicSegment.setFourthControlPoint(m_cubicSegments.first().firstControlPoint());
|
lastCubicSegment.setFourthControlPoint(m_cubicSegments.constFirst().firstControlPoint());
|
||||||
lastCubicSegment.fourthControlPoint().setPathModelNode(pathNode);
|
lastCubicSegment.fourthControlPoint().setPathModelNode(pathNode);
|
||||||
lastCubicSegment.fourthControlPoint().setPointType(StartAndEndPoint);
|
lastCubicSegment.fourthControlPoint().setPointType(StartAndEndPoint);
|
||||||
}
|
}
|
||||||
@@ -588,8 +588,8 @@ void PathItem::splitCubicSegment(CubicSegment &cubicSegment, double t)
|
|||||||
void PathItem::closePath()
|
void PathItem::closePath()
|
||||||
{
|
{
|
||||||
if (!m_cubicSegments.isEmpty()) {
|
if (!m_cubicSegments.isEmpty()) {
|
||||||
CubicSegment firstCubicSegment = m_cubicSegments.first();
|
const CubicSegment &firstCubicSegment = m_cubicSegments.constFirst();
|
||||||
CubicSegment lastCubicSegment = m_cubicSegments.last();
|
CubicSegment lastCubicSegment = m_cubicSegments.constLast();
|
||||||
lastCubicSegment.setFourthControlPoint(firstCubicSegment.firstControlPoint());
|
lastCubicSegment.setFourthControlPoint(firstCubicSegment.firstControlPoint());
|
||||||
writePathAsCubicSegmentsOnly();
|
writePathAsCubicSegmentsOnly();
|
||||||
}
|
}
|
||||||
@@ -598,8 +598,8 @@ void PathItem::closePath()
|
|||||||
void PathItem::openPath()
|
void PathItem::openPath()
|
||||||
{
|
{
|
||||||
if (!m_cubicSegments.isEmpty()) {
|
if (!m_cubicSegments.isEmpty()) {
|
||||||
CubicSegment firstCubicSegment = m_cubicSegments.first();
|
const CubicSegment &firstCubicSegment = m_cubicSegments.constFirst();
|
||||||
CubicSegment lastCubicSegment = m_cubicSegments.last();
|
CubicSegment lastCubicSegment = m_cubicSegments.constLast();
|
||||||
QPointF newEndPoint = firstCubicSegment.firstControlPoint().coordinate();
|
QPointF newEndPoint = firstCubicSegment.firstControlPoint().coordinate();
|
||||||
newEndPoint.setX(newEndPoint.x() + 10.);
|
newEndPoint.setX(newEndPoint.x() + 10.);
|
||||||
lastCubicSegment.setFourthControlPoint(ControlPoint(newEndPoint));
|
lastCubicSegment.setFourthControlPoint(ControlPoint(newEndPoint));
|
||||||
@@ -694,7 +694,7 @@ const QList<ControlPoint> PathItem::controlPoints() const
|
|||||||
controlPointList.reserve((m_cubicSegments.count() * 4));
|
controlPointList.reserve((m_cubicSegments.count() * 4));
|
||||||
|
|
||||||
if (!m_cubicSegments.isEmpty())
|
if (!m_cubicSegments.isEmpty())
|
||||||
controlPointList.append(m_cubicSegments.first().firstControlPoint());
|
controlPointList.append(m_cubicSegments.constFirst().firstControlPoint());
|
||||||
|
|
||||||
foreach (const CubicSegment &cubicSegment, m_cubicSegments) {
|
foreach (const CubicSegment &cubicSegment, m_cubicSegments) {
|
||||||
controlPointList.append(cubicSegment.secondControlPoint());
|
controlPointList.append(cubicSegment.secondControlPoint());
|
||||||
@@ -908,8 +908,8 @@ bool PathItem::isClosedPath() const
|
|||||||
if (m_cubicSegments.isEmpty())
|
if (m_cubicSegments.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ControlPoint firstControlPoint = m_cubicSegments.first().firstControlPoint();
|
ControlPoint firstControlPoint = m_cubicSegments.constFirst().firstControlPoint();
|
||||||
ControlPoint lastControlPoint = m_cubicSegments.last().fourthControlPoint();
|
ControlPoint lastControlPoint = m_cubicSegments.constLast().fourthControlPoint();
|
||||||
|
|
||||||
return firstControlPoint == lastControlPoint;
|
return firstControlPoint == lastControlPoint;
|
||||||
}
|
}
|
||||||
@@ -939,7 +939,7 @@ void PathItem::removeEditPoint(const ControlPoint &controlPoint)
|
|||||||
QList<CubicSegment> cubicSegments = cubicSegmentsContainingControlPoint(controlPoint, m_cubicSegments);
|
QList<CubicSegment> cubicSegments = cubicSegmentsContainingControlPoint(controlPoint, m_cubicSegments);
|
||||||
|
|
||||||
if (cubicSegments.count() == 1) {
|
if (cubicSegments.count() == 1) {
|
||||||
m_cubicSegments.removeOne(cubicSegments.first());
|
m_cubicSegments.removeOne(cubicSegments.constFirst());
|
||||||
} else if (cubicSegments.count() == 2){
|
} else if (cubicSegments.count() == 2){
|
||||||
CubicSegment mergedCubicSegment = CubicSegment::create();
|
CubicSegment mergedCubicSegment = CubicSegment::create();
|
||||||
CubicSegment firstCubicSegment = cubicSegments.at(0);
|
CubicSegment firstCubicSegment = cubicSegments.at(0);
|
||||||
|
@@ -80,7 +80,7 @@ static ControlPoint getControlPoint(const QList<ControlPoint> &selectedPoints, c
|
|||||||
return selectedPoints.at(offsetIndex);
|
return selectedPoints.at(offsetIndex);
|
||||||
else if (isClosedPath) {
|
else if (isClosedPath) {
|
||||||
if (offsetIndex == -1)
|
if (offsetIndex == -1)
|
||||||
return selectedPoints.last();
|
return selectedPoints.constLast();
|
||||||
else if (offsetIndex < selectedPoints.count())
|
else if (offsetIndex < selectedPoints.count())
|
||||||
return selectedPoints.at(1);
|
return selectedPoints.at(1);
|
||||||
}
|
}
|
||||||
|
@@ -257,8 +257,8 @@ void PathTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
|
|||||||
m_pathItem->writePathToProperty();
|
m_pathItem->writePathToProperty();
|
||||||
|
|
||||||
delete m_pathItem.data();
|
delete m_pathItem.data();
|
||||||
if (!itemList.isEmpty() && hasPathProperty(itemList.first())) {
|
if (!itemList.isEmpty() && hasPathProperty(itemList.constFirst())) {
|
||||||
FormEditorItem *formEditorItem = itemList.first();
|
FormEditorItem *formEditorItem = itemList.constFirst();
|
||||||
m_pathItem = new PathItem(scene());
|
m_pathItem = new PathItem(scene());
|
||||||
m_pathItem->setParentItem(scene()->manipulatorLayerItem());
|
m_pathItem->setParentItem(scene()->manipulatorLayerItem());
|
||||||
m_pathItem->setFormEditorItem(formEditorItem);
|
m_pathItem->setFormEditorItem(formEditorItem);
|
||||||
|
@@ -192,7 +192,7 @@ static QString baseDirectory(const QUrl &url)
|
|||||||
void SourceTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
|
void SourceTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
|
||||||
{
|
{
|
||||||
if (!itemList.isEmpty()) {
|
if (!itemList.isEmpty()) {
|
||||||
m_formEditorItem = itemList.first();
|
m_formEditorItem = itemList.constFirst();
|
||||||
m_oldFileName = m_formEditorItem->qmlItemNode().modelValue("source").toString();
|
m_oldFileName = m_formEditorItem->qmlItemNode().modelValue("source").toString();
|
||||||
|
|
||||||
QString openDirectory = baseDirectory(view()->model()->fileUrl());
|
QString openDirectory = baseDirectory(view()->model()->fileUrl());
|
||||||
|
@@ -209,7 +209,7 @@ void TextTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
|
|||||||
view()->changeToSelectionTool();
|
view()->changeToSelectionTool();
|
||||||
}
|
}
|
||||||
if (!itemList.isEmpty()) {
|
if (!itemList.isEmpty()) {
|
||||||
FormEditorItem *formEditorItem = itemList.first();
|
FormEditorItem *formEditorItem = itemList.constFirst();
|
||||||
m_textItem = new TextEditItem(scene());
|
m_textItem = new TextEditItem(scene());
|
||||||
textItem()->setParentItem(scene()->manipulatorLayerItem());
|
textItem()->setParentItem(scene()->manipulatorLayerItem());
|
||||||
textItem()->setFormEditorItem(formEditorItem);
|
textItem()->setFormEditorItem(formEditorItem);
|
||||||
|
@@ -361,7 +361,7 @@ void QmlDesignerPlugin::jumpTextCursorToSelectedModelNode()
|
|||||||
// visual editor -> text editor
|
// visual editor -> text editor
|
||||||
ModelNode selectedNode;
|
ModelNode selectedNode;
|
||||||
if (!rewriterView()->selectedModelNodes().isEmpty())
|
if (!rewriterView()->selectedModelNodes().isEmpty())
|
||||||
selectedNode = rewriterView()->selectedModelNodes().first();
|
selectedNode = rewriterView()->selectedModelNodes().constFirst();
|
||||||
|
|
||||||
if (selectedNode.isValid()) {
|
if (selectedNode.isValid()) {
|
||||||
const int nodeOffset = rewriterView()->nodeOffset(selectedNode);
|
const int nodeOffset = rewriterView()->nodeOffset(selectedNode);
|
||||||
@@ -477,7 +477,7 @@ double QmlDesignerPlugin::formEditorDevicePixelRatio()
|
|||||||
const QList<QWindow *> topLevelWindows = QApplication::topLevelWindows();
|
const QList<QWindow *> topLevelWindows = QApplication::topLevelWindows();
|
||||||
if (topLevelWindows.isEmpty())
|
if (topLevelWindows.isEmpty())
|
||||||
return 1;
|
return 1;
|
||||||
return topLevelWindows.first()->screen()->devicePixelRatio();
|
return topLevelWindows.constFirst()->screen()->devicePixelRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlDesignerPlugin *QmlDesignerPlugin::instance()
|
QmlDesignerPlugin *QmlDesignerPlugin::instance()
|
||||||
|
Reference in New Issue
Block a user