Skip to content

Commit

Permalink
Debugger: Get rid of SG* prefix in qtquick2 plugin
Browse files Browse the repository at this point in the history
Change-Id: Ib8a40d633c169652258480748cfc162593ed9f6c
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
  • Loading branch information
Kai Koehne authored and Qt by Nokia committed Dec 20, 2011
1 parent 0eca9de commit b899758
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 76 deletions.
Expand Up @@ -39,20 +39,20 @@
**
****************************************************************************/

#include "sghighlight.h"
#include "highlight.h"

#include <QtGui/QPainter>

namespace QmlJSDebugger {
namespace QtQuick2 {

SGHighlight::SGHighlight(QQuickItem *item, QQuickItem *parent)
Highlight::Highlight(QQuickItem *item, QQuickItem *parent)
: QQuickPaintedItem(parent)
{
setItem(item);
}

void SGHighlight::setItem(QQuickItem *item)
void Highlight::setItem(QQuickItem *item)
{
if (m_item)
m_item.data()->disconnect(this);
Expand All @@ -71,7 +71,7 @@ void SGHighlight::setItem(QQuickItem *item)
adjust();
}

void SGHighlight::adjust()
void Highlight::adjust()
{
const QQuickItem *item = m_item.data();
setSize(QSizeF(item->width(), item->height()));
Expand All @@ -81,14 +81,14 @@ void SGHighlight::adjust()
}


void SGSelectionHighlight::paint(QPainter *painter)
void SelectionHighlight::paint(QPainter *painter)
{
painter->setPen(QColor(108, 141, 221));
painter->drawRect(QRect(0, 0, width() - 1, height() - 1));
}


void SGHoverHighlight::paint(QPainter *painter)
void HoverHighlight::paint(QPainter *painter)
{
painter->setPen(QPen(QColor(0, 22, 159)));
painter->drawRect(QRect(1, 1, width() - 3, height() - 3));
Expand Down
Expand Up @@ -39,22 +39,22 @@
**
****************************************************************************/

#ifndef SGHIGHLIGHT_H
#define SGHIGHLIGHT_H
#ifndef HIGHLIGHT_H
#define HIGHLIGHT_H

#include <QtCore/QWeakPointer>
#include <QtQuick/QQuickPaintedItem>

namespace QmlJSDebugger {
namespace QtQuick2 {

class SGHighlight : public QQuickPaintedItem
class Highlight : public QQuickPaintedItem
{
Q_OBJECT

public:
SGHighlight(QQuickItem *parent) : QQuickPaintedItem(parent) {}
SGHighlight(QQuickItem *item, QQuickItem *parent);
Highlight(QQuickItem *parent) : QQuickPaintedItem(parent) {}
Highlight(QQuickItem *item, QQuickItem *parent);

void setItem(QQuickItem *item);

Expand All @@ -68,11 +68,11 @@ private slots:
/**
* A highlight suitable for indicating selection.
*/
class SGSelectionHighlight : public SGHighlight
class SelectionHighlight : public Highlight
{
public:
SGSelectionHighlight(QQuickItem *item, QQuickItem *parent)
: SGHighlight(item, parent)
SelectionHighlight(QQuickItem *item, QQuickItem *parent)
: Highlight(item, parent)
{}

void paint(QPainter *painter);
Expand All @@ -81,11 +81,11 @@ class SGSelectionHighlight : public SGHighlight
/**
* A highlight suitable for indicating hover.
*/
class SGHoverHighlight : public SGHighlight
class HoverHighlight : public Highlight
{
public:
SGHoverHighlight(QQuickItem *parent)
: SGHighlight(parent)
HoverHighlight(QQuickItem *parent)
: Highlight(parent)
{
setZ(1); // hover highlight on top of selection highlight
}
Expand All @@ -96,4 +96,4 @@ class SGHoverHighlight : public SGHighlight
} // namespace QtQuick2
} // namespace QmlJSDebugger

#endif // SGHIGHLIGHT_H
#endif // HIGHLIGHT_H
12 changes: 6 additions & 6 deletions src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro
Expand Up @@ -11,17 +11,17 @@ INCLUDEPATH *= $$PWD $$PWD/../shared

SOURCES += \
qtquick2plugin.cpp \
sghighlight.cpp \
sgselectiontool.cpp \
sgviewinspector.cpp \
highlight.cpp \
selectiontool.cpp \
qquickviewinspector.cpp \
../shared/abstracttool.cpp \
../shared/abstractviewinspector.cpp

HEADERS += \
qtquick2plugin.h \
sghighlight.h \
sgselectiontool.h \
sgviewinspector.h \
highlight.h \
selectiontool.h \
qquickviewinspector.h \
../shared/abstracttool.h \
../shared/abstractviewinspector.h \
../shared/qdeclarativeinspectorprotocol.h \
Expand Down
Expand Up @@ -39,11 +39,11 @@
**
****************************************************************************/

#include "sgviewinspector.h"
#include "qquickviewinspector.h"

#include "qdeclarativeinspectorprotocol.h"
#include "sghighlight.h"
#include "sgselectiontool.h"
#include "highlight.h"
#include "selectiontool.h"

#include <QtQuick/private/qquickitem_p.h>

Expand Down Expand Up @@ -115,11 +115,11 @@ static QQuickItem *itemAt(QQuickItem *item, const QPointF &pos, QQuickItem *over
}


SGViewInspector::SGViewInspector(QQuickView *view, QObject *parent) :
QQuickViewInspector::QQuickViewInspector(QQuickView *view, QObject *parent) :
AbstractViewInspector(parent),
m_view(view),
m_overlay(new QQuickItem),
m_selectionTool(new SGSelectionTool(this)),
m_selectionTool(new SelectionTool(this)),
m_designMode(true)
{
// Try to make sure the overlay is always on top
Expand All @@ -132,7 +132,7 @@ SGViewInspector::SGViewInspector(QQuickView *view, QObject *parent) :
setCurrentTool(m_selectionTool);
}

void SGViewInspector::changeCurrentObjects(const QList<QObject*> &objects)
void QQuickViewInspector::changeCurrentObjects(const QList<QObject*> &objects)
{
QList<QQuickItem*> items;
foreach (QObject *obj, objects)
Expand All @@ -142,13 +142,13 @@ void SGViewInspector::changeCurrentObjects(const QList<QObject*> &objects)
syncSelectedItems(items);
}

void SGViewInspector::reloadView()
void QQuickViewInspector::reloadView()
{
// TODO
emit reloadRequested();
}

void SGViewInspector::reparentQmlObject(QObject *object, QObject *newParent)
void QQuickViewInspector::reparentQmlObject(QObject *object, QObject *newParent)
{
if (!newParent)
return;
Expand All @@ -160,7 +160,7 @@ void SGViewInspector::reparentQmlObject(QObject *object, QObject *newParent)
item->setParentItem(newParentItem);
}

void SGViewInspector::changeTool(InspectorProtocol::Tool tool)
void QQuickViewInspector::changeTool(InspectorProtocol::Tool tool)
{
switch (tool) {
case InspectorProtocol::ColorPickerTool:
Expand Down Expand Up @@ -192,12 +192,12 @@ QWindow *getMasterWindow(QWindow *w)
return w;
}

Qt::WindowFlags SGViewInspector::windowFlags() const
Qt::WindowFlags QQuickViewInspector::windowFlags() const
{
return getMasterWindow(m_view)->windowFlags();
}

void SGViewInspector::setWindowFlags(Qt::WindowFlags flags)
void QQuickViewInspector::setWindowFlags(Qt::WindowFlags flags)
{
QWindow *w = getMasterWindow(m_view);
w->setWindowFlags(flags);
Expand All @@ -206,26 +206,26 @@ void SGViewInspector::setWindowFlags(Qt::WindowFlags flags)
w->setVisible(true);
}

QDeclarativeEngine *SGViewInspector::declarativeEngine() const
QDeclarativeEngine *QQuickViewInspector::declarativeEngine() const
{
return m_view->engine();
}

QQuickItem *SGViewInspector::topVisibleItemAt(const QPointF &pos) const
QQuickItem *QQuickViewInspector::topVisibleItemAt(const QPointF &pos) const
{
QQuickItem *root = m_view->rootItem();
return itemAt(root, root->mapFromScene(pos), m_overlay);
}

QList<QQuickItem *> SGViewInspector::itemsAt(const QPointF &pos) const
QList<QQuickItem *> QQuickViewInspector::itemsAt(const QPointF &pos) const
{
QQuickItem *root = m_view->rootItem();
QList<QQuickItem *> resultList;
collectItemsAt(root, root->mapFromScene(pos), m_overlay, resultList);
return resultList;
}

QList<QQuickItem*> SGViewInspector::selectedItems() const
QList<QQuickItem*> QQuickViewInspector::selectedItems() const
{
QList<QQuickItem *> selection;
foreach (const QWeakPointer<QQuickItem> &selectedItem, m_selectedItems) {
Expand All @@ -235,7 +235,7 @@ QList<QQuickItem*> SGViewInspector::selectedItems() const
return selection;
}

void SGViewInspector::setSelectedItems(const QList<QQuickItem *> &items)
void QQuickViewInspector::setSelectedItems(const QList<QQuickItem *> &items)
{
if (!syncSelectedItems(items))
return;
Expand All @@ -247,7 +247,7 @@ void SGViewInspector::setSelectedItems(const QList<QQuickItem *> &items)
sendCurrentObjects(objectList);
}

bool SGViewInspector::syncSelectedItems(const QList<QQuickItem *> &items)
bool QQuickViewInspector::syncSelectedItems(const QList<QQuickItem *> &items)
{
bool selectionChanged = false;

Expand All @@ -272,29 +272,29 @@ bool SGViewInspector::syncSelectedItems(const QList<QQuickItem *> &items)
selectionChanged = true;
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(removeFromSelectedItems(QObject*)));
m_selectedItems.append(item);
m_highlightItems.insert(item, new SGSelectionHighlight(item, m_overlay));
m_highlightItems.insert(item, new SelectionHighlight(item, m_overlay));
}

return selectionChanged;
}

void SGViewInspector::removeFromSelectedItems(QObject *object)
void QQuickViewInspector::removeFromSelectedItems(QObject *object)
{
if (QQuickItem *item = qobject_cast<QQuickItem*>(object)) {
if (m_selectedItems.removeOne(item))
delete m_highlightItems.take(item);
}
}

bool SGViewInspector::eventFilter(QObject *obj, QEvent *event)
bool QQuickViewInspector::eventFilter(QObject *obj, QEvent *event)
{
if (obj != m_view)
return QObject::eventFilter(obj, event);

return AbstractViewInspector::eventFilter(obj, event);
}

bool SGViewInspector::mouseMoveEvent(QMouseEvent *event)
bool QQuickViewInspector::mouseMoveEvent(QMouseEvent *event)
{
// TODO
// if (QQuickItem *item = topVisibleItemAt(event->pos()))
Expand All @@ -305,7 +305,7 @@ bool SGViewInspector::mouseMoveEvent(QMouseEvent *event)
return AbstractViewInspector::mouseMoveEvent(event);
}

QString SGViewInspector::titleForItem(QQuickItem *item) const
QString QQuickViewInspector::titleForItem(QQuickItem *item) const
{
QString className = QLatin1String(item->metaObject()->className());
QString objectStringId = idStringForObject(item);
Expand Down
Expand Up @@ -39,8 +39,8 @@
**
****************************************************************************/

#ifndef QSGVIEWINSPECTOR_H
#define QSGVIEWINSPECTOR_H
#ifndef QQUICKVIEWINSPECTOR_H
#define QQUICKVIEWINSPECTOR_H

#include "abstractviewinspector.h"

Expand All @@ -55,14 +55,14 @@ QT_END_NAMESPACE
namespace QmlJSDebugger {
namespace QtQuick2 {

class SGSelectionTool;
class SGSelectionHighlight;
class SelectionTool;
class SelectionHighlight;

class SGViewInspector : public AbstractViewInspector
class QQuickViewInspector : public AbstractViewInspector
{
Q_OBJECT
public:
explicit SGViewInspector(QQuickView *view, QObject *parent = 0);
explicit QQuickViewInspector(QQuickView *view, QObject *parent = 0);

// AbstractViewInspector
void changeCurrentObjects(const QList<QObject*> &objects);
Expand Down Expand Up @@ -98,15 +98,15 @@ private slots:
QQuickView *m_view;
QQuickItem *m_overlay;

SGSelectionTool *m_selectionTool;
SelectionTool *m_selectionTool;

QList<QWeakPointer<QQuickItem> > m_selectedItems;
QHash<QQuickItem*, SGSelectionHighlight*> m_highlightItems;
QHash<QQuickItem*, SelectionHighlight*> m_highlightItems;

bool m_designMode;
};

} // namespace QtQuick2
} // namespace QmlJSDebugger

#endif // QSGVIEWINSPECTOR_H
#endif // QQUICKVIEWINSPECTOR_H
4 changes: 2 additions & 2 deletions src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp
Expand Up @@ -40,7 +40,7 @@
****************************************************************************/

#include "qtquick2plugin.h"
#include "sgviewinspector.h"
#include "qquickviewinspector.h"

#include <QtCore/qplugin.h>
#include <QtDeclarative/private/qdeclarativeinspectorservice_p.h>
Expand Down Expand Up @@ -68,7 +68,7 @@ void QtQuick2Plugin::activate(QObject *view)
{
QQuickView *qtQuickView = qobject_cast<QQuickView*>(view);
Q_ASSERT(qtQuickView);
m_inspector = new SGViewInspector(qtQuickView, qtQuickView);
m_inspector = new QQuickViewInspector(qtQuickView, qtQuickView);
}

void QtQuick2Plugin::deactivate()
Expand Down

0 comments on commit b899758

Please sign in to comment.