Pass QList as const reference when possible
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Tue, 17 May 2011 09:23:10 +0000 (11:23 +0200)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Fri, 27 May 2011 13:40:36 +0000 (15:40 +0200)
Avoids some reference counting.

Reviewed-by: Kai Koehne
Change-Id: I4de83aa4df6833fa2287ac1854bbb0052d15cee9
(cherry picked from commit bdd8f188ac352c99ee218318a59089f387a31d60)

src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp
src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h
src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h

index 41346ff..5d2ab09 100644 (file)
@@ -557,7 +557,7 @@ void QDeclarativeViewObserverPrivate::changeTool(Constants::DesignTool tool,
     }
 }
 
-void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList<QGraphicsItem *> items)
+void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(const QList<QGraphicsItem *> &items)
 {
     foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) {
         if (QGraphicsItem *item = obj.data()) {
@@ -582,7 +582,7 @@ void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList<QGraphicsIt
     currentTool->updateSelectedItems();
 }
 
-void QDeclarativeViewObserverPrivate::setSelectedItems(QList<QGraphicsItem *> items)
+void QDeclarativeViewObserverPrivate::setSelectedItems(const QList<QGraphicsItem *> &items)
 {
     QList<QWeakPointer<QGraphicsObject> > oldList = currentSelection;
     setSelectedItemsForTools(items);
@@ -633,7 +633,8 @@ void QDeclarativeViewObserverPrivate::highlight(QGraphicsObject * item, ContextF
     highlight(QList<QGraphicsObject*>() << item, flags);
 }
 
-void QDeclarativeViewObserverPrivate::highlight(QList<QGraphicsObject *> items, ContextFlags flags)
+void QDeclarativeViewObserverPrivate::highlight(const QList<QGraphicsObject *> &items,
+                                                ContextFlags flags)
 {
     if (items.isEmpty())
         return;
@@ -1064,7 +1065,7 @@ void QDeclarativeViewObserver::sendDesignModeBehavior(bool inDesignMode)
     data->debugService->sendMessage(message);
 }
 
-void QDeclarativeViewObserver::sendCurrentObjects(QList<QObject*> objects)
+void QDeclarativeViewObserver::sendCurrentObjects(const QList<QObject*> &objects)
 {
     QByteArray message;
     QDataStream ds(&message, QIODevice::WriteOnly);
index 4d66cae..86d0d95 100644 (file)
@@ -78,7 +78,7 @@ public:
     bool showAppOnTop() const;
 
     void sendDesignModeBehavior(bool inDesignMode);
-    void sendCurrentObjects(QList<QObject*> items);
+    void sendCurrentObjects(const QList<QObject*> &);
     void sendAnimationSpeed(qreal slowDownFactor);
     void sendAnimationPaused(bool paused);
     void sendCurrentTool(Constants::DesignTool toolId);
index 57dae45..8809591 100644 (file)
@@ -117,15 +117,16 @@ public:
     QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
     QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
 
-    void setSelectedItemsForTools(QList<QGraphicsItem *> items);
-    void setSelectedItems(QList<QGraphicsItem *> items);
+    void setSelectedItemsForTools(const QList<QGraphicsItem *> &items);
+    void setSelectedItems(const QList<QGraphicsItem *> &items);
     QList<QGraphicsItem *> selectedItems() const;
 
     void changeTool(Constants::DesignTool tool,
                     Constants::ToolFlags flags = Constants::NoToolFlags);
 
     void clearHighlight();
-    void highlight(QList<QGraphicsObject *> item, ContextFlags flags = ContextSensitive);
+    void highlight(const QList<QGraphicsObject *> &item,
+                   ContextFlags flags = ContextSensitive);
     void highlight(QGraphicsObject *item, ContextFlags flags = ContextSensitive);
 
     bool mouseInsideContextItem() const;