Commit a5d3fcbc authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

QmlJSDebugger: Code cosmetics

parent b23c24d2
......@@ -151,7 +151,7 @@ QList<QGraphicsObject*> AbstractLiveEditTool::toGraphicsObjectList(const QList<Q
&itemList)
{
QList<QGraphicsObject*> gfxObjects;
foreach(QGraphicsItem *item, itemList) {
foreach (QGraphicsItem *item, itemList) {
QGraphicsObject *obj = item->toGraphicsObject();
if (obj)
gfxObjects << obj;
......
......@@ -106,7 +106,7 @@ void BoundingRectHighlighter::animTimeout()
qreal alpha = m_animFrame / float(AnimFrames);
foreach(BoundingBox *box, m_boxes) {
foreach (BoundingBox *box, m_boxes) {
box->highlightPolygonEdge->setOpacity(alpha);
}
}
......@@ -116,7 +116,7 @@ void BoundingRectHighlighter::clear()
if (m_boxes.length()) {
m_animTimer->stop();
foreach(BoundingBox *box, m_boxes) {
foreach (BoundingBox *box, m_boxes) {
freeBoundingBox(box);
}
}
......@@ -124,7 +124,7 @@ void BoundingRectHighlighter::clear()
BoundingBox *BoundingRectHighlighter::boxFor(QGraphicsObject *item) const
{
foreach(BoundingBox *box, m_boxes) {
foreach (BoundingBox *box, m_boxes) {
if (box->highlightedObject.data() == item) {
return box;
}
......@@ -140,7 +140,7 @@ void BoundingRectHighlighter::highlight(QList<QGraphicsObject*> items)
bool animate = false;
QList<BoundingBox *> newBoxes;
foreach(QGraphicsObject *itemToHighlight, items) {
foreach (QGraphicsObject *itemToHighlight, items) {
BoundingBox *box = boxFor(itemToHighlight);
if (!box) {
box = createBoundingBox(itemToHighlight);
......@@ -227,7 +227,7 @@ void BoundingRectHighlighter::freeBoundingBox(BoundingBox *box)
void BoundingRectHighlighter::itemDestroyed(QObject *obj)
{
foreach(BoundingBox *box, m_boxes) {
foreach (BoundingBox *box, m_boxes) {
if (box->highlightedObject.data() == obj) {
freeBoundingBox(box);
break;
......@@ -237,7 +237,7 @@ void BoundingRectHighlighter::itemDestroyed(QObject *obj)
void BoundingRectHighlighter::highlightAll(bool animate)
{
foreach(BoundingBox *box, m_boxes) {
foreach (BoundingBox *box, m_boxes) {
if (box && box->highlightedObject.isNull()) {
// clear all highlights
clear();
......
......@@ -93,7 +93,7 @@ QPolygonF LiveSelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item,
polygon = polygon.united(bounding);
}
foreach(QGraphicsItem *child, item->childItems()) {
foreach (QGraphicsItem *child, item->childItems()) {
if (!QDeclarativeViewObserverPrivate::get(m_view)->isEditorItem(child))
addBoundingRectToPolygon(child, polygon);
}
......
......@@ -96,11 +96,9 @@ bool LiveSelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) c
if (selectedItems.isEmpty())
return false;
foreach(QGraphicsItem *item, itemList) {
if (selectedItems.contains(item)) {
foreach (QGraphicsItem *item, itemList)
if (selectedItems.contains(item))
return true;
}
}
return false;
}
......@@ -143,7 +141,7 @@ void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint
bool addKeySequence = true;
int i = 0;
foreach(QGraphicsItem * const item, itemList) {
foreach (QGraphicsItem * const item, itemList) {
QString itemTitle = titleForItem(item);
QAction *elementAction = contextMenu.addAction(itemTitle, this,
SLOT(contextMenuElementSelected()));
......@@ -237,7 +235,7 @@ void LiveSelectionTool::hoverMoveEvent(QMouseEvent * event)
// QList<QGraphicsItem*> itemList = view()->items(event->pos());
// if (!itemList.isEmpty() && !m_rubberbandSelectionMode) {
//
// foreach(QGraphicsItem *item, itemList) {
// foreach (QGraphicsItem *item, itemList) {
// if (item->type() == Constants::ResizeHandleItemType) {
// ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(item);
// if (resizeHandle)
......@@ -305,7 +303,6 @@ void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event)
void LiveSelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
{
}
void LiveSelectionTool::keyPressEvent(QKeyEvent *event)
......@@ -373,7 +370,6 @@ void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems)
void LiveSelectionTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
{
}
void LiveSelectionTool::clear()
......@@ -387,7 +383,7 @@ void LiveSelectionTool::clear()
void LiveSelectionTool::selectedItemsChanged(const QList<QGraphicsItem*> &itemList)
{
foreach(QWeakPointer<QGraphicsObject> obj, m_selectedItemList) {
foreach (QWeakPointer<QGraphicsObject> obj, m_selectedItemList) {
if (!obj.isNull()) {
disconnect(obj.data(), SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
disconnect(obj.data(), SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
......@@ -400,7 +396,7 @@ void LiveSelectionTool::selectedItemsChanged(const QList<QGraphicsItem*> &itemLi
QList<QGraphicsObject*> objects = toGraphicsObjectList(itemList);
m_selectedItemList.clear();
foreach(QGraphicsObject *obj, objects) {
foreach (QGraphicsObject *obj, objects) {
m_selectedItemList.append(obj);
connect(obj, SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
connect(obj, SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
......
......@@ -76,7 +76,7 @@ void LiveSingleSelectionManipulator::select(SelectionType selectionType,
{
QGraphicsItem *selectedItem = 0;
foreach(QGraphicsItem* item, items)
foreach (QGraphicsItem* item, items)
{
//FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (item
......
......@@ -43,7 +43,7 @@
namespace QmlJSDebugger {
QmlToolbar::QmlToolbar(QWidget *parent)
QmlToolBar::QmlToolBar(QWidget *parent)
: QToolBar(parent)
, m_emitSignals(true)
, m_isRunning(false)
......@@ -150,40 +150,40 @@ QmlToolbar::QmlToolbar(QWidget *parent)
connect(ui->fromQml, SIGNAL(triggered()), SLOT(activateFromQml()));
}
QmlToolbar::~QmlToolbar()
QmlToolBar::~QmlToolBar()
{
delete ui;
}
void QmlToolbar::activateColorPicker()
void QmlToolBar::activateColorPicker()
{
m_emitSignals = false;
activateColorPickerOnClick();
m_emitSignals = true;
}
void QmlToolbar::activateSelectTool()
void QmlToolBar::activateSelectTool()
{
m_emitSignals = false;
activateSelectToolOnClick();
m_emitSignals = true;
}
void QmlToolbar::activateMarqueeSelectTool()
void QmlToolBar::activateMarqueeSelectTool()
{
m_emitSignals = false;
activateMarqueeSelectToolOnClick();
m_emitSignals = true;
}
void QmlToolbar::activateZoom()
void QmlToolBar::activateZoom()
{
m_emitSignals = false;
activateZoomOnClick();
m_emitSignals = true;
}
void QmlToolbar::setAnimationSpeed(qreal slowdownFactor)
void QmlToolBar::setAnimationSpeed(qreal slowdownFactor)
{
m_emitSignals = false;
if (slowdownFactor != 0) {
......@@ -209,38 +209,38 @@ void QmlToolbar::setAnimationSpeed(qreal slowdownFactor)
m_emitSignals = true;
}
void QmlToolbar::changeToDefaultAnimSpeed()
void QmlToolBar::changeToDefaultAnimSpeed()
{
m_animationSpeed = 1.0f;
updatePlayAction();
}
void QmlToolbar::changeToHalfAnimSpeed()
void QmlToolBar::changeToHalfAnimSpeed()
{
m_animationSpeed = 2.0f;
updatePlayAction();
}
void QmlToolbar::changeToFourthAnimSpeed()
void QmlToolBar::changeToFourthAnimSpeed()
{
m_animationSpeed = 4.0f;
updatePlayAction();
}
void QmlToolbar::changeToEighthAnimSpeed()
void QmlToolBar::changeToEighthAnimSpeed()
{
m_animationSpeed = 8.0f;
updatePlayAction();
}
void QmlToolbar::changeToTenthAnimSpeed()
void QmlToolBar::changeToTenthAnimSpeed()
{
m_animationSpeed = 10.0f;
updatePlayAction();
}
void QmlToolbar::setDesignModeBehavior(bool inDesignMode)
void QmlToolBar::setDesignModeBehavior(bool inDesignMode)
{
m_emitSignals = false;
ui->designmode->setChecked(inDesignMode);
......@@ -248,7 +248,7 @@ void QmlToolbar::setDesignModeBehavior(bool inDesignMode)
m_emitSignals = true;
}
void QmlToolbar::setDesignModeBehaviorOnClick(bool checked)
void QmlToolBar::setDesignModeBehaviorOnClick(bool checked)
{
ui->play->setEnabled(checked);
ui->select->setEnabled(checked);
......@@ -262,12 +262,12 @@ void QmlToolbar::setDesignModeBehaviorOnClick(bool checked)
emit designModeBehaviorChanged(checked);
}
void QmlToolbar::setColorBoxColor(const QColor &color)
void QmlToolBar::setColorBoxColor(const QColor &color)
{
ui->colorBox->setColor(color);
}
void QmlToolbar::activatePlayOnClick()
void QmlToolBar::activatePlayOnClick()
{
if (m_isRunning) {
updatePauseAction();
......@@ -276,7 +276,7 @@ void QmlToolbar::activatePlayOnClick()
}
}
void QmlToolbar::updatePlayAction()
void QmlToolBar::updatePlayAction()
{
m_isRunning = true;
ui->play->setIcon(ui->pauseIcon);
......@@ -287,7 +287,7 @@ void QmlToolbar::updatePlayAction()
emit animationSpeedChanged(m_animationSpeed);
}
void QmlToolbar::updatePauseAction()
void QmlToolBar::updatePauseAction()
{
m_isRunning = false;
ui->play->setIcon(ui->playIcon);
......@@ -295,7 +295,7 @@ void QmlToolbar::updatePauseAction()
emit animationSpeedChanged(0.0f);
}
void QmlToolbar::activateColorPickerOnClick()
void QmlToolBar::activateColorPickerOnClick()
{
ui->zoom->setChecked(false);
ui->select->setChecked(false);
......@@ -309,7 +309,7 @@ void QmlToolbar::activateColorPickerOnClick()
}
}
void QmlToolbar::activateSelectToolOnClick()
void QmlToolBar::activateSelectToolOnClick()
{
ui->zoom->setChecked(false);
ui->selectMarquee->setChecked(false);
......@@ -323,7 +323,7 @@ void QmlToolbar::activateSelectToolOnClick()
}
}
void QmlToolbar::activateMarqueeSelectToolOnClick()
void QmlToolBar::activateMarqueeSelectToolOnClick()
{
ui->zoom->setChecked(false);
ui->select->setChecked(false);
......@@ -337,7 +337,7 @@ void QmlToolbar::activateMarqueeSelectToolOnClick()
}
}
void QmlToolbar::activateZoomOnClick()
void QmlToolBar::activateZoomOnClick()
{
ui->select->setChecked(false);
ui->selectMarquee->setChecked(false);
......@@ -351,13 +351,13 @@ void QmlToolbar::activateZoomOnClick()
}
}
void QmlToolbar::activateFromQml()
void QmlToolBar::activateFromQml()
{
if (m_emitSignals)
emit applyChangesFromQmlFileSelected();
}
void QmlToolbar::activateToQml()
void QmlToolBar::activateToQml()
{
if (m_emitSignals)
emit applyChangesToQmlFileSelected();
......
......@@ -43,13 +43,13 @@ namespace QmlJSDebugger {
class ToolBarColorBox;
class QmlToolbar : public QToolBar
class QmlToolBar : public QToolBar
{
Q_OBJECT
public:
explicit QmlToolbar(QWidget *parent = 0);
~QmlToolbar();
explicit QmlToolBar(QWidget *parent = 0);
~QmlToolBar();
public slots:
void setDesignModeBehavior(bool inDesignMode);
......
......@@ -182,7 +182,7 @@ void SubcomponentEditorTool::setCurrentItem(QGraphicsItem* contextItem)
//if (parentClassName.contains(QRegExp("_QMLTYPE_\\d+")))
bool containsSelectableItems = false;
foreach(QGraphicsItem *item, gfxObject->childItems()) {
foreach (QGraphicsItem *item, gfxObject->childItems()) {
if (item->type() == Constants::EditorItemType
|| item->type() == Constants::ResizeHandleItemType)
{
......
......@@ -310,12 +310,12 @@ qreal ZoomTool::nextZoomScale(ZoomDirection direction) const
<< 48.0f;
if (direction == ZoomIn) {
for(int i = 0; i < zoomScales.length(); ++i) {
for (int i = 0; i < zoomScales.length(); ++i) {
if (zoomScales[i] > m_currentScale || i == zoomScales.length() - 1)
return zoomScales[i];
}
} else {
for(int i = zoomScales.length() - 1; i >= 0; --i) {
for (int i = zoomScales.length() - 1; i >= 0; --i) {
if (zoomScales[i] < m_currentScale || i == 0)
return zoomScales[i];
}
......
......@@ -62,7 +62,7 @@ public:
QDeclarativeView *declarativeView();
QToolBar *toolbar() const;
QToolBar *toolBar() const;
static QString idStringForObject(QObject *obj);
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
......
......@@ -77,7 +77,7 @@ void QDeclarativeObserverService::messageReceived(const QByteArray &message)
ds >> itemCount;
QList<QObject*> selectedObjects;
for(int i = 0; i < itemCount; ++i) {
for (int i = 0; i < itemCount; ++i) {
int debugId = -1;
ds >> debugId;
QObject *obj = objectForId(debugId);
......@@ -134,7 +134,7 @@ void QDeclarativeObserverService::messageReceived(const QByteArray &message)
int itemCount;
ds >> itemCount;
m_stringIdForObjectId.clear();
for(int i = 0; i < itemCount; ++i) {
for (int i = 0; i < itemCount; ++i) {
int itemDebugId;
QString itemIdString;
ds >> itemDebugId
......@@ -170,7 +170,7 @@ void QDeclarativeObserverService::setCurrentObjects(QList<QObject*> objects)
ds << QByteArray("CURRENT_OBJECTS_CHANGED")
<< objects.length();
foreach(QObject *object, objects) {
foreach (QObject *object, objects) {
int id = idForObject(object);
ds << id;
}
......
......@@ -65,7 +65,7 @@ QDeclarativeViewObserverPrivate::QDeclarativeViewObserverPrivate(QDeclarativeVie
showAppOnTop(false),
executionPaused(false),
slowdownFactor(1.0f),
toolbar(0)
toolBar(0)
{
}
......@@ -145,9 +145,8 @@ void QDeclarativeViewObserver::setObserverContext(int contextIndex)
{
if (data->subcomponentEditorTool->contextIndex() != contextIndex) {
QGraphicsObject *object = data->subcomponentEditorTool->setContext(contextIndex);
if (object) {
if (object)
setSelectedItems(QList<QGraphicsItem*>() << object);
}
}
}
......@@ -163,9 +162,9 @@ void QDeclarativeViewObserverPrivate::setViewport(QWidget *widget)
if (viewport.data() == widget)
return;
if (viewport) {
if (viewport)
viewport.data()->removeEventFilter(q);
}
viewport = widget;
if (viewport) {
// make sure we get mouse move events
......@@ -192,7 +191,7 @@ bool QDeclarativeViewObserver::eventFilter(QObject *obj, QEvent *event)
return QObject::eventFilter(obj, event);
}
//Event from viewport
// Event from viewport
switch (event->type()) {
case QEvent::Leave: {
if (leaveEvent(event))
......@@ -297,18 +296,17 @@ bool QDeclarativeViewObserver::mouseReleaseEvent(QMouseEvent *event)
bool QDeclarativeViewObserver::keyPressEvent(QKeyEvent *event)
{
if (!data->designModeBehavior) {
if (!data->designModeBehavior)
return false;
}
data->currentTool->keyPressEvent(event);
return true;
}
bool QDeclarativeViewObserver::keyReleaseEvent(QKeyEvent *event)
{
if (!data->designModeBehavior) {
if (!data->designModeBehavior)
return false;
}
switch(event->key()) {
case Qt::Key_V:
......@@ -352,7 +350,7 @@ void QDeclarativeViewObserverPrivate::_q_createQmlObject(const QString &qml, QOb
return;
QString imports;
foreach(const QString &s, importList) {
foreach (const QString &s, importList) {
imports += s + "\n";
}
......@@ -366,9 +364,8 @@ void QDeclarativeViewObserverPrivate::_q_createQmlObject(const QString &qml, QOb
newObject->setParent(parent);
QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent);
QDeclarativeItem *newItem = qobject_cast<QDeclarativeItem*>(newObject);
if (parentItem && newItem) {
if (parentItem && newItem)
newItem->setParentItem(parentItem);
}
}
}
......@@ -380,9 +377,8 @@ void QDeclarativeViewObserverPrivate::_q_reparentQmlObject(QObject *object, QObj
object->setParent(newParent);
QDeclarativeItem *newParentItem = qobject_cast<QDeclarativeItem*>(newParent);
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(object);
if (newParentItem && item) {
if (newParentItem && item)
item->setParentItem(newParentItem);
}
}
void QDeclarativeViewObserverPrivate::_q_clearComponentCache()
......@@ -393,9 +389,8 @@ void QDeclarativeViewObserverPrivate::_q_clearComponentCache()
void QDeclarativeViewObserverPrivate::_q_removeFromSelection(QObject *obj)
{
QList<QGraphicsItem*> items = selectedItems();
if (QGraphicsItem *item = dynamic_cast<QGraphicsItem*>(obj)) {
if (QGraphicsItem *item = dynamic_cast<QGraphicsItem*>(obj))
items.removeOne(item);
}
setSelectedItems(items);
}
......@@ -430,10 +425,8 @@ bool QDeclarativeViewObserver::mouseDoubleClickEvent(QMouseEvent *event)
data->subcomponentEditorTool->mouseDoubleClickEvent(event);
if ((event->buttons() & Qt::LeftButton) && itemToEnter) {
QGraphicsObject *objectToEnter = itemToEnter->toGraphicsObject();
if (objectToEnter) {
if (QGraphicsObject *objectToEnter = itemToEnter->toGraphicsObject())
setSelectedItems(QList<QGraphicsItem*>() << objectToEnter);
}
}
return true;
......@@ -461,7 +454,7 @@ void QDeclarativeViewObserver::setDesignModeBehavior(bool value)
{
emit designModeBehaviorChanged(value);
data->toolbar->setDesignModeBehavior(value);
data->toolBar->setDesignModeBehavior(value);
data->debugService->setDesignModeBehavior(value);
data->designModeBehavior = value;
......@@ -495,11 +488,11 @@ void QDeclarativeViewObserver::setShowAppOnTop(bool appOnTop)
while (rootWidget->parentWidget())
rootWidget = rootWidget->parentWidget();
Qt::WindowFlags flags = rootWidget->windowFlags();
if (appOnTop) {
if (appOnTop)
flags |= Qt::WindowStaysOnTopHint;
} else {
else
flags &= ~Qt::WindowStaysOnTopHint;
}
rootWidget->setWindowFlags(flags);
rootWidget->show();
}
......@@ -538,8 +531,7 @@ void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList<QGraphicsIt
foreach (QGraphicsItem *item, items) {
if (item) {
QGraphicsObject *obj = item->toGraphicsObject();
if (obj) {
if (QGraphicsObject *obj = item->toGraphicsObject()) {
QObject::connect(obj, SIGNAL(destroyed(QObject*)),
this, SLOT(_q_removeFromSelection(QObject*)));
currentSelection.append(obj);
......@@ -568,7 +560,7 @@ void QDeclarativeViewObserverPrivate::setSelectedItems(QList<QGraphicsItem *> it
QList<QGraphicsItem *> QDeclarativeViewObserverPrivate::selectedItems()
{
QList<QGraphicsItem *> selection;
foreach(const QWeakPointer<QGraphicsObject> &selectedObject, currentSelection) {
foreach (const QWeakPointer<QGraphicsObject> &selectedObject, currentSelection) {
if (selectedObject.data())
selection << selectedObject.data();
}
......@@ -607,7 +599,7 @@ void QDeclarativeViewObserverPrivate::highlight(QList<QGraphicsObject *> items,
return;
QList<QGraphicsObject*> objectList;
foreach(QGraphicsItem *item, items) {
foreach (QGraphicsItem *item, items) {
QGraphicsItem *child = item;
if (flags & ContextSensitive)
child = subcomponentEditorTool->firstChildOfContext(item);
......@@ -714,11 +706,10 @@ void QDeclarativeViewObserver::changeAnimationSpeed(qreal slowdownFactor)
{
data->slowdownFactor = slowdownFactor;
if (data->slowdownFactor != 0) {
if (data->slowdownFactor != 0)
continueExecution(data->slowdownFactor);
} else {
else
pauseExecution();
}
}
void QDeclarativeViewObserver::continueExecution(qreal slowdownFactor)
......@@ -751,14 +742,13 @@ void QDeclarativeViewObserver::pauseExecution()
void QDeclarativeViewObserverPrivate::_q_applyChangesFromClient()
{
}