summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWater-Team <water@pad.test.qt.nokia.com>2011-07-06 01:00:16 +0200
committerWater-Team <water@pad.test.qt.nokia.com>2011-07-06 01:00:16 +0200
commit43e116ea63ffd96d945fbaabeafb2374e5f18e9e (patch)
tree52de6bdb9812b6b98aef7092d1530ea3cb3fb867
parent9ef422955154199e6f2d5569cb4074a5967f53e9 (diff)
parent74d8577f5b71a593a968d0723aaca19a5249b7d3 (diff)
Merge branch '4.8-upstream' into master-water
-rw-r--r--src/corelib/codecs/qtextcodec_symbian.cpp4
-rw-r--r--src/declarative/debugger/qjsdebuggeragent.cpp42
-rw-r--r--src/declarative/debugger/qjsdebuggeragent_p.h12
-rw-r--r--src/declarative/debugger/qjsdebugservice.cpp53
-rw-r--r--src/declarative/debugger/qjsdebugservice_p.h24
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp136
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h15
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp97
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp133
-rw-r--r--src/gui/dialogs/qerrormessage.cpp16
-rw-r--r--src/gui/dialogs/qmessagebox.cpp11
-rw-r--r--src/gui/styles/qs60style.cpp10
-rw-r--r--src/gui/styles/qs60style_p.h2
-rw-r--r--src/gui/styles/qs60style_s60.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp54
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstracttool.h85
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp611
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h178
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp17
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool_p.h)25
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp11
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h)12
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp45
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool_p.h)29
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem_p.h)10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator_p.h)12
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp11
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator_p.h)10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle_p.h)10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp35
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool_p.h)26
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator_p.h)10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar_p.h)12
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem_p.h)10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox_p.h)10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp16
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h (renamed from src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool_p.h)18
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp7
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp755
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h100
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h126
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h152
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro36
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants.h (renamed from src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h)17
-rw-r--r--tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp101
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp47
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp8
-rw-r--r--tools/qmlplugindump/main.cpp69
-rw-r--r--tools/qmlplugindump/qmlplugindump.pro17
59 files changed, 1915 insertions, 1414 deletions
diff --git a/src/corelib/codecs/qtextcodec_symbian.cpp b/src/corelib/codecs/qtextcodec_symbian.cpp
index c8a7357edc..504a7c81e1 100644
--- a/src/corelib/codecs/qtextcodec_symbian.cpp
+++ b/src/corelib/codecs/qtextcodec_symbian.cpp
@@ -119,11 +119,13 @@ static const QSymbianCodecInitData codecsData[] = {
{ /*271082504*/ 271082504, 0, "portuguese_locking_gsm7ext\0" },
{ /*271082505*/ 271082505, 0, "portuguese_locking_single\0" },
{ /*271082506*/ 271082506, 0, "spanish_gsm7_single\0" },
+ { /*271082762*/ 271082762, 0, "hkscs_2004\0" },
{ /*271085624*/ 271085624, 114, "GB18030\0" },
{ /*536929574*/ 536929574, 38, "EUC-KR\0" },
{ /*536936703*/ 536936703, 0, "CP949\0" },
{ /*536936705*/ 536936705, 37, "ISO-2022-KR\0csISO2022KR\0" },
- { /*536941517*/ 536941517, 36, "KS_C_5601-1987\0iso-ir-149\0KS_C_5601-1989\0KSC_5601\0Korean\0csKSC56011987\0" }
+ { /*536941517*/ 536941517, 36, "KS_C_5601-1987\0iso-ir-149\0KS_C_5601-1989\0KSC_5601\0Korean\0csKSC56011987\0" },
+ { /*537124345*/ 537124345, 119, "KZ-1048\0" }
};
diff --git a/src/declarative/debugger/qjsdebuggeragent.cpp b/src/declarative/debugger/qjsdebuggeragent.cpp
index dff637b7da..683032b5db 100644
--- a/src/declarative/debugger/qjsdebuggeragent.cpp
+++ b/src/declarative/debugger/qjsdebuggeragent.cpp
@@ -41,6 +41,7 @@
#include "private/qjsdebuggeragent_p.h"
#include "private/qdeclarativedebughelper_p.h"
+#include "private/qjsdebugservice_p.h"
#include <QtCore/qdatetime.h>
#include <QtCore/qcoreapplication.h>
@@ -56,7 +57,7 @@ class QJSDebuggerAgentPrivate
{
public:
QJSDebuggerAgentPrivate(QJSDebuggerAgent *q)
- : q(q), state(NoState), isInitialized(false)
+ : q(q), state(NoState), isInitialized(false), coverageEnabled(false)
{}
void continueExec();
@@ -80,6 +81,7 @@ public:
QStringList watchExpressions;
QSet<qint64> knownObjectIds;
bool isInitialized;
+ bool coverageEnabled;
};
namespace {
@@ -261,6 +263,12 @@ bool QJSDebuggerAgent::isInitialized() const
return d->isInitialized;
}
+void QJSDebuggerAgent::setCoverageEnabled(bool enabled)
+{
+ d->isInitialized = true;
+ d->coverageEnabled = enabled;
+}
+
void QJSDebuggerAgent::setBreakpoints(const JSAgentBreakpoints &breakpoints)
{
d->breakpoints = breakpoints;
@@ -417,10 +425,16 @@ void QJSDebuggerAgent::setProperty(qint64 objectId,
\reimp
*/
void QJSDebuggerAgent::scriptLoad(qint64 id, const QString &program,
- const QString &fileName, int)
+ const QString &fileName, int baseLineNumber)
{
- Q_UNUSED(program);
d->filenames.insert(id, fileName);
+
+ if (d->coverageEnabled) {
+ JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageScriptLoad,
+ id, program, fileName, baseLineNumber,
+ 0, 0, QString()};
+ QJSDebugService::instance()->processMessage(rd);
+ }
}
/*!
@@ -450,8 +464,14 @@ void QJSDebuggerAgent::contextPop()
*/
void QJSDebuggerAgent::functionEntry(qint64 scriptId)
{
- Q_UNUSED(scriptId);
d->stepDepth++;
+
+ if (d->coverageEnabled) {
+ JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageFuncEntry,
+ scriptId, QString(), QString(), 0, 0, 0, QString()};
+ QJSDebugService::instance()->processMessage(rd);
+ QJSDebugService::instance()->m_timer.restart();
+ }
}
/*!
@@ -459,9 +479,13 @@ void QJSDebuggerAgent::functionEntry(qint64 scriptId)
*/
void QJSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue)
{
- Q_UNUSED(scriptId);
- Q_UNUSED(returnValue);
d->stepDepth--;
+
+ if (d->coverageEnabled) {
+ JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageFuncExit,
+ scriptId, QString(), QString(), 0, 0, 0, returnValue.toString()};
+ QJSDebugService::instance()->processMessage(rd);
+ }
}
/*!
@@ -470,6 +494,12 @@ void QJSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnV
void QJSDebuggerAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
{
d->positionChange(scriptId, lineNumber, columnNumber);
+
+ if (d->coverageEnabled) {
+ JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoveragePosChange,
+ scriptId, QString(), QString(), 0, lineNumber, columnNumber, QString()};
+ QJSDebugService::instance()->processMessage(rd);
+ }
}
void QJSDebuggerAgentPrivate::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
diff --git a/src/declarative/debugger/qjsdebuggeragent_p.h b/src/declarative/debugger/qjsdebuggeragent_p.h
index 4b27fc82ad..e999080570 100644
--- a/src/declarative/debugger/qjsdebuggeragent_p.h
+++ b/src/declarative/debugger/qjsdebuggeragent_p.h
@@ -78,6 +78,17 @@ enum JSDebuggerState
StoppedState
};
+enum JSCoverageMessage {
+ CoverageLocation,
+ CoverageScriptLoad,
+ CoveragePosChange,
+ CoverageFuncEntry,
+ CoverageFuncExit,
+ CoverageComplete,
+
+ CoverageMaximumMessage
+};
+
struct JSAgentWatchData
{
QByteArray exp;
@@ -165,6 +176,7 @@ public:
void stepInto();
void stepOut();
void continueExecution();
+ void setCoverageEnabled(bool enabled);
JSAgentWatchData executeExpression(const QString &expr);
QList<JSAgentWatchData> expandObjectById(quint64 objectId);
diff --git a/src/declarative/debugger/qjsdebugservice.cpp b/src/declarative/debugger/qjsdebugservice.cpp
index ad84f656f7..03d1f7654b 100644
--- a/src/declarative/debugger/qjsdebugservice.cpp
+++ b/src/declarative/debugger/qjsdebugservice.cpp
@@ -49,10 +49,22 @@
Q_GLOBAL_STATIC(QJSDebugService, serviceInstance)
+// convert to a QByteArray that can be sent to the debug client
+QByteArray JSAgentCoverageData::toByteArray() const
+{
+ QByteArray data;
+ //### using QDataStream is relatively expensive
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << prefix << time << messageType << scriptId << program << fileName << baseLineNumber
+ << lineNumber << columnNumber << returnValue;
+ return data;
+}
+
QJSDebugService::QJSDebugService(QObject *parent)
: QDeclarativeDebugService(QLatin1String("JSDebugger"), parent)
- , m_agent(0)
+ , m_agent(0), m_deferredSend(true)
{
+ m_timer.start();
}
QJSDebugService::~QJSDebugService()
@@ -186,6 +198,13 @@ void QJSDebugService::messageReceived(const QByteArray &message)
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("PONG") << ping;
sendMessage(reply);
+ } else if (command == "COVERAGE") {
+ bool enabled;
+ ds >> enabled;
+ m_agent->setCoverageEnabled(enabled);
+ if (!enabled) {
+ sendMessages();
+ }
} else {
qDebug() << Q_FUNC_INFO << "Unknown command" << command;
}
@@ -206,3 +225,35 @@ void QJSDebugService::executionStopped(bool becauseOfException,
<< becauseOfException << exception;
sendMessage(reply);
}
+
+/*
+ Either send the message directly, or queue up
+ a list of messages to send later (via sendMessages)
+*/
+void QJSDebugService::processMessage(const JSAgentCoverageData &message)
+{
+ if (m_deferredSend)
+ m_data.append(message);
+ else
+ sendMessage(message.toByteArray());
+}
+
+/*
+ Send the messages queued up by processMessage
+*/
+void QJSDebugService::sendMessages()
+{
+ if (m_deferredSend) {
+ //### this is a suboptimal way to send batched messages
+ for (int i = 0; i < m_data.count(); ++i)
+ sendMessage(m_data.at(i).toByteArray());
+ m_data.clear();
+
+ //indicate completion
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << QByteArray("COVERAGE") << (qint64)-1 << (int)CoverageComplete;
+ sendMessage(data);
+ }
+}
+
diff --git a/src/declarative/debugger/qjsdebugservice_p.h b/src/declarative/debugger/qjsdebugservice_p.h
index 7e7642eb9b..4f99043b37 100644
--- a/src/declarative/debugger/qjsdebugservice_p.h
+++ b/src/declarative/debugger/qjsdebugservice_p.h
@@ -54,6 +54,7 @@
//
#include <QtCore/QPointer>
+#include <QElapsedTimer>
#include "private/qdeclarativedebugservice_p.h"
@@ -66,6 +67,23 @@ QT_MODULE(Declarative)
class QDeclarativeEngine;
class QJSDebuggerAgent;
+struct JSAgentCoverageData
+{
+ QByteArray prefix;
+ qint64 time;
+ int messageType;
+
+ qint64 scriptId;
+ QString program;
+ QString fileName;
+ int baseLineNumber;
+ int lineNumber;
+ int columnNumber;
+ QString returnValue;
+
+ QByteArray toByteArray() const;
+};
+
class QJSDebugService : public QDeclarativeDebugService
{
Q_OBJECT
@@ -78,6 +96,9 @@ public:
void addEngine(QDeclarativeEngine *);
void removeEngine(QDeclarativeEngine *);
+ void processMessage(const JSAgentCoverageData &message);
+
+ QElapsedTimer m_timer;
protected:
void statusChanged(Status status);
@@ -88,8 +109,11 @@ private Q_SLOTS:
const QString &exception);
private:
+ void sendMessages();
QList<QDeclarativeEngine *> m_engines;
QPointer<QJSDebuggerAgent> m_agent;
+ bool m_deferredSend;
+ QList<JSAgentCoverageData> m_data;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 13bb8ef113..d5c58df28f 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -168,9 +168,7 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
: contentItem(new QDeclarativeItem)
, hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX)
, vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY)
- , flickingHorizontally(false), flickingVertically(false)
, hMoved(false), vMoved(false)
- , movingHorizontally(false), movingVertically(false)
, stealMouse(false), pressed(false), interactive(true), calcVelocity(false)
, deceleration(QML_FLICK_DEFAULTDECELERATION)
, maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY), reportedVelocitySmoothing(100)
@@ -294,18 +292,18 @@ void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal
else
timeline.accel(data.move, v, deceleration, maxDistance);
timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
- if (!flickingHorizontally && q->xflick()) {
- flickingHorizontally = true;
+ if (!hData.flicking && q->xflick()) {
+ hData.flicking = true;
emit q->flickingChanged();
emit q->flickingHorizontallyChanged();
- if (!flickingVertically)
+ if (!vData.flicking)
emit q->flickStarted();
}
- if (!flickingVertically && q->yflick()) {
- flickingVertically = true;
+ if (!vData.flicking && q->yflick()) {
+ vData.flicking = true;
emit q->flickingChanged();
emit q->flickingVerticallyChanged();
- if (!flickingHorizontally)
+ if (!hData.flicking)
emit q->flickStarted();
}
} else {
@@ -614,11 +612,11 @@ void QDeclarativeFlickable::setInteractive(bool interactive)
Q_D(QDeclarativeFlickable);
if (interactive != d->interactive) {
d->interactive = interactive;
- if (!interactive && (d->flickingHorizontally || d->flickingVertically)) {
+ if (!interactive && (d->hData.flicking || d->vData.flicking)) {
d->timeline.clear();
d->vTime = d->timeline.time();
- d->flickingHorizontally = false;
- d->flickingVertically = false;
+ d->hData.flicking = false;
+ d->vData.flicking = false;
emit flickingChanged();
emit flickingHorizontallyChanged();
emit flickingVerticallyChanged();
@@ -771,8 +769,8 @@ void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEven
pressPos = event->pos();
hData.pressPos = hData.move.value();
vData.pressPos = vData.move.value();
- flickingHorizontally = false;
- flickingVertically = false;
+ hData.flicking = false;
+ vData.flicking = false;
QDeclarativeItemPrivate::start(pressTime);
QDeclarativeItemPrivate::start(velocityTime);
}
@@ -897,31 +895,33 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv
return;
// if we drag then pause before release we should not cause a flick.
- if (QDeclarativeItemPrivate::elapsed(lastPosTime) < 100) {
- vData.updateVelocity();
- hData.updateVelocity();
- } else {
- hData.velocity = 0.0;
- vData.velocity = 0.0;
- }
+ qint64 elapsed = QDeclarativeItemPrivate::elapsed(lastPosTime);
+ vData.updateVelocity();
+ hData.updateVelocity();
vTime = timeline.time();
- qreal velocity = vData.velocity;
+ qreal velocity = elapsed < 100 ? vData.velocity : 0;
if (vData.atBeginning || vData.atEnd)
velocity /= 2;
- if (qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold)
+ if (q->yflick() && qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) {
+ velocityTimeline.reset(vData.smoothVelocity);
+ vData.smoothVelocity.setValue(-velocity);
flickY(velocity);
- else
+ } else {
fixupY();
+ }
- velocity = hData.velocity;
+ velocity = elapsed < 100 ? hData.velocity : 0;
if (hData.atBeginning || hData.atEnd)
velocity /= 2;
- if (qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold)
+ if (q->xflick() && qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) {
+ velocityTimeline.reset(hData.smoothVelocity);
+ hData.smoothVelocity.setValue(-velocity);
flickX(velocity);
- else
+ } else {
fixupX();
+ }
if (!timeline.isActive())
q->movementEnding();
@@ -978,9 +978,9 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
valid = true;
}
if (valid) {
- d->flickingVertically = false;
+ d->vData.flicking = false;
d->flickY(d->vData.velocity);
- if (d->flickingVertically) {
+ if (d->vData.flicking) {
d->vMoved = true;
movementStarting();
}
@@ -996,9 +996,9 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
valid = true;
}
if (valid) {
- d->flickingHorizontally = false;
+ d->hData.flicking = false;
d->flickX(d->hData.velocity);
- if (d->flickingHorizontally) {
+ if (d->hData.flicking) {
d->hMoved = true;
movementStarting();
}
@@ -1121,19 +1121,25 @@ void QDeclarativeFlickable::viewportMoved()
qreal prevX = d->lastFlickablePosition.x();
qreal prevY = d->lastFlickablePosition.y();
- d->velocityTimeline.clear();
if (d->pressed || d->calcVelocity) {
int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime);
if (elapsed > 0) {
qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed;
+ if (qAbs(horizontalVelocity) > 0) {
+ d->velocityTimeline.reset(d->hData.smoothVelocity);
+ d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing);
+ }
qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed;
- d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing);
+ if (qAbs(verticalVelocity) > 0) {
+ d->velocityTimeline.reset(d->vData.smoothVelocity);
+ d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing);
+ }
}
} else {
if (d->timeline.time() > d->vTime) {
+ d->velocityTimeline.clear();
qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / (d->timeline.time() - d->vTime);
qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / (d->timeline.time() - d->vTime);
d->hData.smoothVelocity.setValue(horizontalVelocity);
@@ -1141,7 +1147,7 @@ void QDeclarativeFlickable::viewportMoved()
}
}
- if (!d->vData.inOvershoot && !d->vData.fixingUp && d->flickingVertically
+ if (!d->vData.inOvershoot && !d->vData.fixingUp && d->vData.flicking
&& (d->vData.move.value() > minYExtent() || d->vData.move.value() < maxYExtent())
&& qAbs(d->vData.smoothVelocity.value()) > 100) {
// Increase deceleration if we've passed a bound
@@ -1151,7 +1157,7 @@ void QDeclarativeFlickable::viewportMoved()
d->timeline.accel(d->vData.move, -d->vData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance);
d->timeline.callback(QDeclarativeTimeLineCallback(&d->vData.move, d->fixupY_callback, d));
}
- if (!d->hData.inOvershoot && !d->hData.fixingUp && d->flickingHorizontally
+ if (!d->hData.inOvershoot && !d->hData.fixingUp && d->hData.flicking
&& (d->hData.move.value() > minXExtent() || d->hData.move.value() < maxXExtent())
&& qAbs(d->hData.smoothVelocity.value()) > 100) {
// Increase deceleration if we've passed a bound
@@ -1183,7 +1189,7 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry,
emit contentWidthChanged();
}
// Make sure that we're entirely in view.
- if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
+ if (!d->pressed && !d->hData.moving && !d->vData.moving) {
d->fixupMode = QDeclarativeFlickablePrivate::Immediate;
d->fixupX();
}
@@ -1196,7 +1202,7 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry,
emit contentHeightChanged();
}
// Make sure that we're entirely in view.
- if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
+ if (!d->pressed && !d->hData.moving && !d->vData.moving) {
d->fixupMode = QDeclarativeFlickablePrivate::Immediate;
d->fixupY();
}
@@ -1351,7 +1357,7 @@ void QDeclarativeFlickable::setContentWidth(qreal w)
else
d->contentItem->setWidth(w);
// Make sure that we're entirely in view.
- if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
+ if (!d->pressed && !d->hData.moving && !d->vData.moving) {
d->fixupMode = QDeclarativeFlickablePrivate::Immediate;
d->fixupX();
} else if (!d->pressed && d->hData.fixingUp) {
@@ -1379,7 +1385,7 @@ void QDeclarativeFlickable::setContentHeight(qreal h)
else
d->contentItem->setHeight(h);
// Make sure that we're entirely in view.
- if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
+ if (!d->pressed && !d->hData.moving && !d->vData.moving) {
d->fixupMode = QDeclarativeFlickablePrivate::Immediate;
d->fixupY();
} else if (!d->pressed && d->vData.fixingUp) {
@@ -1635,7 +1641,7 @@ void QDeclarativeFlickable::setFlickDeceleration(qreal deceleration)
bool QDeclarativeFlickable::isFlicking() const
{
Q_D(const QDeclarativeFlickable);
- return d->flickingHorizontally || d->flickingVertically;
+ return d->hData.flicking || d->vData.flicking;
}
/*!
@@ -1649,13 +1655,13 @@ bool QDeclarativeFlickable::isFlicking() const
bool QDeclarativeFlickable::isFlickingHorizontally() const
{
Q_D(const QDeclarativeFlickable);
- return d->flickingHorizontally;
+ return d->hData.flicking;
}
bool QDeclarativeFlickable::isFlickingVertically() const
{
Q_D(const QDeclarativeFlickable);
- return d->flickingVertically;
+ return d->vData.flicking;
}
/*!
@@ -1691,7 +1697,7 @@ void QDeclarativeFlickable::setPressDelay(int delay)
bool QDeclarativeFlickable::isMoving() const
{
Q_D(const QDeclarativeFlickable);
- return d->movingHorizontally || d->movingVertically;
+ return d->hData.moving || d->vData.moving;
}
/*!
@@ -1706,30 +1712,30 @@ bool QDeclarativeFlickable::isMoving() const
bool QDeclarativeFlickable::isMovingHorizontally() const
{
Q_D(const QDeclarativeFlickable);
- return d->movingHorizontally;
+ return d->hData.moving;
}
bool QDeclarativeFlickable::isMovingVertically() const
{
Q_D(const QDeclarativeFlickable);
- return d->movingVertically;
+ return d->vData.moving;
}
void QDeclarativeFlickable::movementStarting()
{
Q_D(QDeclarativeFlickable);
- if (d->hMoved && !d->movingHorizontally) {
- d->movingHorizontally = true;
+ if (d->hMoved && !d->hData.moving) {
+ d->hData.moving = true;
emit movingChanged();
emit movingHorizontallyChanged();
- if (!d->movingVertically)
+ if (!d->vData.moving)
emit movementStarted();
}
- else if (d->vMoved && !d->movingVertically) {
- d->movingVertically = true;
+ else if (d->vMoved && !d->vData.moving) {
+ d->vData.moving = true;
emit movingChanged();
emit movingVerticallyChanged();
- if (!d->movingHorizontally)
+ if (!d->hData.moving)
emit movementStarted();
}
}
@@ -1746,20 +1752,20 @@ void QDeclarativeFlickable::movementEnding()
void QDeclarativeFlickable::movementXEnding()
{
Q_D(QDeclarativeFlickable);
- if (d->flickingHorizontally) {
- d->flickingHorizontally = false;
+ if (d->hData.flicking) {
+ d->hData.flicking = false;
emit flickingChanged();
emit flickingHorizontallyChanged();
- if (!d->flickingVertically)
+ if (!d->vData.flicking)
emit flickEnded();
}
if (!d->pressed && !d->stealMouse) {
- if (d->movingHorizontally) {
- d->movingHorizontally = false;
+ if (d->hData.moving) {
+ d->hData.moving = false;
d->hMoved = false;
emit movingChanged();
emit movingHorizontallyChanged();
- if (!d->movingVertically)
+ if (!d->vData.moving)
emit movementEnded();
}
}
@@ -1769,20 +1775,20 @@ void QDeclarativeFlickable::movementXEnding()
void QDeclarativeFlickable::movementYEnding()
{
Q_D(QDeclarativeFlickable);
- if (d->flickingVertically) {
- d->flickingVertically = false;
+ if (d->vData.flicking) {
+ d->vData.flicking = false;
emit flickingChanged();
emit flickingVerticallyChanged();
- if (!d->flickingHorizontally)
+ if (!d->hData.flicking)
emit flickEnded();
}
if (!d->pressed && !d->stealMouse) {
- if (d->movingVertically) {
- d->movingVertically = false;
+ if (d->vData.moving) {
+ d->vData.moving = false;
d->vMoved = false;
emit movingChanged();
emit movingVerticallyChanged();
- if (!d->movingHorizontally)
+ if (!d->hData.moving)
emit movementEnded();
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index 46b2104384..d73a907e39 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -63,11 +63,16 @@
#include <qdeclarativeanimation_p_p.h>
#include <qdatetime.h>
+#include "qplatformdefs.h"
QT_BEGIN_NAMESPACE
// Really slow flicks can be annoying.
-const qreal MinimumFlickVelocity = 75.0;
+#ifndef QML_FLICK_MINVELOCITY
+#define QML_FLICK_MINVELOCITY 175
+#endif
+
+const qreal MinimumFlickVelocity = QML_FLICK_MINVELOCITY;
class QDeclarativeFlickableVisibleArea;
class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener
@@ -94,7 +99,7 @@ public:
struct AxisData {
AxisData(QDeclarativeFlickablePrivate *fp, void (QDeclarativeFlickablePrivate::*func)(qreal))
: move(fp, func), viewSize(-1), smoothVelocity(fp), atEnd(false), atBeginning(true)
- , fixingUp(false), inOvershoot(false)
+ , fixingUp(false), inOvershoot(false), moving(false), flicking(false)
{}
void reset() {
@@ -121,6 +126,8 @@ public:
bool atBeginning : 1;
bool fixingUp : 1;
bool inOvershoot : 1;
+ bool moving : 1;
+ bool flicking : 1;
};
void flickX(qreal velocity);
@@ -152,12 +159,8 @@ public:
AxisData vData;
QDeclarativeTimeLine timeline;
- bool flickingHorizontally : 1;
- bool flickingVertically : 1;
bool hMoved : 1;
bool vMoved : 1;
- bool movingHorizontally : 1;
- bool movingVertically : 1;
bool stealMouse : 1;
bool pressed : 1;
bool interactive : 1;
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index a0264f7076..23433d653e 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -52,9 +52,13 @@
#include <qmath.h>
#include <math.h>
+#include "qplatformdefs.h"
QT_BEGIN_NAMESPACE
+#ifndef QML_FLICK_SNAPONETHRESHOLD
+#define QML_FLICK_SNAPONETHRESHOLD 30
+#endif
//----------------------------------------------------------------------------
@@ -344,9 +348,12 @@ public:
Q_Q(const QDeclarativeGridView);
qreal snapPos = 0;
if (!visibleItems.isEmpty()) {
+ qreal highlightStart = isRightToLeftTopToBottom() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart;
+ pos += highlightStart;
pos += rowSize()/2;
snapPos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize();
snapPos = pos - fmodf(pos - snapPos, qreal(rowSize()));
+ snapPos -= highlightStart;
qreal maxExtent;
qreal minExtent;
if (isRightToLeftTopToBottom()) {
@@ -874,7 +881,7 @@ void QDeclarativeGridViewPrivate::updateHighlight()
{
if ((!currentItem && highlight) || (currentItem && !highlight))
createHighlight();
- if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) {
+ if (currentItem && autoHighlight && highlight && !hData.moving && !vData.moving) {
// auto-update highlight
highlightXAnimator->to = currentItem->item->x();
highlightYAnimator->to = currentItem->item->y();
@@ -1061,6 +1068,18 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
if (snapMode != QDeclarativeGridView::NoSnap) {
qreal tempPosition = isRightToLeftTopToBottom() ? -position()-size() : position();
+ if (snapMode == QDeclarativeGridView::SnapOneRow && moveReason == Mouse) {
+ // if we've been dragged < rowSize()/2 then bias towards the next row
+ qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal bias = 0;
+ if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < rowSize()/2)
+ bias = rowSize()/2;
+ else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -rowSize()/2)
+ bias = -rowSize()/2;
+ if (isRightToLeftTopToBottom())
+ bias = -bias;
+ tempPosition -= bias;
+ }
FxGridItem *topItem = snapItemAt(tempPosition+highlightStart);
FxGridItem *bottomItem = snapItemAt(tempPosition+highlightEnd);
qreal pos;
@@ -1082,25 +1101,13 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
}
} else if (bottomItem) {
if (isRightToLeftTopToBottom())
- pos = qMax(qMin(-bottomItem->rowPos() + highlightStart - size(), -maxExtent), -minExtent);
+ pos = qMax(qMin(-bottomItem->rowPos() + highlightEnd - size(), -maxExtent), -minExtent);
else
- pos = qMax(qMin(bottomItem->rowPos() - highlightStart, -maxExtent), -minExtent);
+ pos = qMax(qMin(bottomItem->rowPos() - highlightEnd, -maxExtent), -minExtent);
} else {
QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
return;
}
- if (currentItem && haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) {
- updateHighlight();
- qreal currPos = currentItem->rowPos();
- if (isRightToLeftTopToBottom())
- pos = -pos-size(); // Transform Pos if required
- if (pos < currPos + rowSize() - highlightEnd)
- pos = currPos + rowSize() - highlightEnd;
- if (pos > currPos - highlightStart)
- pos = currPos - highlightStart;
- if (isRightToLeftTopToBottom())
- pos = -pos-size(); // Untransform
- }
qreal dist = qAbs(data.move + pos);
if (dist > 0) {
timeline.reset(data.move);
@@ -1157,9 +1164,14 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (velocity > 0) {
if (data.move.value() < minExtent) {
if (snapMode == QDeclarativeGridView::SnapOneRow) {
- if (FxGridItem *item = firstVisibleItem()) {
- maxDistance = qAbs(item->rowPos() + dataValue);
- }
+ // if we've been dragged < averageSize/2 then bias towards the next item
+ qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal bias = dist < rowSize()/2 ? rowSize()/2 : 0;
+ if (isRightToLeftTopToBottom())
+ bias = -bias;
+ data.flickTarget = -snapPosAt(-dataValue - bias);
+ maxDistance = qAbs(data.flickTarget - data.move.value());
+ velocity = maxVelocity;
} else {
maxDistance = qAbs(minExtent - data.move.value());
}
@@ -1169,8 +1181,14 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
} else {
if (data.move.value() > maxExtent) {
if (snapMode == QDeclarativeGridView::SnapOneRow) {
- qreal pos = snapPosAt(-dataValue) + (isRightToLeftTopToBottom() ? 0 : rowSize());
- maxDistance = qAbs(pos + dataValue);
+ // if we've been dragged < averageSize/2 then bias towards the next item
+ qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal bias = -dist < rowSize()/2 ? rowSize()/2 : 0;
+ if (isRightToLeftTopToBottom())
+ bias = -bias;
+ data.flickTarget = -snapPosAt(-dataValue + bias);
+ maxDistance = qAbs(data.flickTarget - data.move.value());
+ velocity = -maxVelocity;
} else {
maxDistance = qAbs(maxExtent - data.move.value());
}
@@ -1180,7 +1198,6 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
}
bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds;
- qreal highlightStart = isRightToLeftTopToBottom() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart;
if (maxDistance > 0 || overShoot) {
// This mode requires the grid to stop exactly on a row boundary.
@@ -1200,9 +1217,20 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
dist = qMin(dist, maxDistance);
if (v > 0)
dist = -dist;
- qreal distTemp = isRightToLeftTopToBottom() ? -dist : dist;
- data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + distTemp) + highlightStart;
+ if (snapMode != QDeclarativeGridView::SnapOneRow) {
+ qreal distTemp = isRightToLeftTopToBottom() ? -dist : dist;
+ data.flickTarget = -snapPosAt(-dataValue + distTemp);
+ }
data.flickTarget = isRightToLeftTopToBottom() ? -data.flickTarget+size() : data.flickTarget;
+ if (overShoot) {
+ if (data.flickTarget >= minExtent) {
+ overshootDist = overShootDistance(vSize);
+ data.flickTarget += overshootDist;
+ } else if (data.flickTarget <= maxExtent) {
+ overshootDist = overShootDistance(vSize);
+ data.flickTarget -= overshootDist;
+ }
+ }
qreal adjDist = -data.flickTarget + data.move.value();
if (qAbs(adjDist) > qAbs(dist)) {
// Prevent painfully slow flicking - adjust velocity to suit flickDeceleration
@@ -1223,14 +1251,14 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
timeline.reset(data.move);
timeline.accel(data.move, v, accel, maxDistance + overshootDist);
timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
- if (!flickingHorizontally && q->xflick()) {
- flickingHorizontally = true;
+ if (!hData.flicking && q->xflick()) {
+ hData.flicking = true;
emit q->flickingChanged();
emit q->flickingHorizontallyChanged();
emit q->flickStarted();
}
- if (!flickingVertically && q->yflick()) {
- flickingVertically = true;
+ if (!vData.flicking && q->yflick()) {
+ vData.flicking = true;
emit q->flickingChanged();
emit q->flickingVerticallyChanged();
emit q->flickStarted();
@@ -1554,6 +1582,8 @@ void QDeclarativeGridView::setCurrentIndex(int index)
if (index == d->currentIndex)
return;
if (isComponentComplete() && d->isValid()) {
+ if (d->layoutScheduled)
+ d->layout();
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
d->updateCurrent(index);
} else {
@@ -2098,7 +2128,8 @@ bool QDeclarativeGridView::event(QEvent *event)
{
Q_D(QDeclarativeGridView);
if (event->type() == QEvent::User) {
- d->layout();
+ if (d->layoutScheduled)
+ d->layout();
return true;
}
@@ -2112,7 +2143,7 @@ void QDeclarativeGridView::viewportMoved()
if (!d->itemCount)
return;
d->lazyRelease = true;
- if (d->flickingHorizontally || d->flickingVertically) {
+ if (d->hData.flicking || d->vData.flicking) {
if (yflick()) {
if (d->vData.velocity > 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore;
@@ -2128,7 +2159,7 @@ void QDeclarativeGridView::viewportMoved()
}
}
refill();
- if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically)
+ if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving)
d->moveReason = QDeclarativeGridViewPrivate::Mouse;
if (d->moveReason != QDeclarativeGridViewPrivate::SetIndex) {
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
@@ -2874,7 +2905,6 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
d->itemCount -= count;
bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
bool removedVisible = false;
-
// Remove the items from the visible list, skipping anything already marked for removal
QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
while (it != d->visibleItems.end()) {
@@ -2908,6 +2938,11 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
}
}
+ // If we removed items before visible items a layout may be
+ // required to ensure item 0 is in the first column.
+ if (!removedVisible && modelIndex < d->visibleIndex)
+ d->scheduleLayout();
+
// fix current
if (d->currentIndex >= modelIndex + count) {
d->currentIndex -= count;
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 7a5e433d62..f29f778fcd 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -53,9 +53,14 @@
#include <qlistmodelinterface_p.h>
#include <qmath.h>
#include <QKeyEvent>
+#include "qplatformdefs.h"
QT_BEGIN_NAMESPACE
+#ifndef QML_FLICK_SNAPONETHRESHOLD
+#define QML_FLICK_SNAPONETHRESHOLD 30
+#endif
+
void QDeclarativeViewSection::setProperty(const QString &property)
{
if (property != m_property) {
@@ -234,21 +239,6 @@ public:
return visibleItems.count() ? visibleItems.first() : 0;
}
- FxListItem *nextVisibleItem() const {
- const qreal pos = isRightToLeft() ? -position()-size() : position();
- bool foundFirst = false;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems.at(i);
- if (item->index != -1) {
- if (foundFirst)
- return item;
- else if (item->position() < pos && item->endPosition() > pos)
- foundFirst = true;
- }
- }
- return 0;
- }
-
// Returns the item before modelIndex, if created.
// May return an item marked for removal.
FxListItem *itemBefore(int modelIndex) const {
@@ -1009,7 +999,7 @@ void QDeclarativeListViewPrivate::updateHighlight()
{
if ((!currentItem && highlight) || (currentItem && !highlight))
createHighlight();
- if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) {
+ if (currentItem && autoHighlight && highlight && !hData.moving && !vData.moving) {
// auto-update highlight
highlightPosAnimator->to = isRightToLeft()
? -currentItem->itemPosition()-currentItem->itemSize()
@@ -1320,29 +1310,20 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
highlightEnd = highlightRangeEnd;
}
- if (currentItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange
- && moveReason != QDeclarativeListViewPrivate::SetIndex) {
- updateHighlight();
- qreal pos = currentItem->itemPosition();
- if (viewPos < pos + currentItem->itemSize() - highlightEnd)
- viewPos = pos + currentItem->itemSize() - highlightEnd;
- if (viewPos > pos - highlightStart)
- viewPos = pos - highlightStart;
- if (isRightToLeft())
- viewPos = -viewPos-size();
-
- timeline.reset(data.move);
- if (viewPos != position()) {
- if (fixupMode != Immediate) {
- timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
- data.fixingUp = true;
- } else {
- timeline.set(data.move, -viewPos);
- }
- }
- vTime = timeline.time();
- } else if (snapMode != QDeclarativeListView::NoSnap && moveReason != QDeclarativeListViewPrivate::SetIndex) {
+ if (snapMode != QDeclarativeListView::NoSnap && moveReason != QDeclarativeListViewPrivate::SetIndex) {
qreal tempPosition = isRightToLeft() ? -position()-size() : position();
+ if (snapMode == QDeclarativeListView::SnapOneItem && moveReason == Mouse) {
+ // if we've been dragged < averageSize/2 then bias towards the next item
+ qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal bias = 0;
+ if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < averageSize/2)
+ bias = averageSize/2;
+ else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -averageSize/2)
+ bias = -averageSize/2;
+ if (isRightToLeft())
+ bias = -bias;
+ tempPosition -= bias;
+ }
FxListItem *topItem = snapItemAt(tempPosition+highlightStart);
FxListItem *bottomItem = snapItemAt(tempPosition+highlightEnd);
qreal pos;
@@ -1358,9 +1339,9 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
}
} else if (bottomItem && isInBounds) {
if (isRightToLeft())
- pos = qMax(qMin(-bottomItem->position() + highlightStart - size(), -maxExtent), -minExtent);
+ pos = qMax(qMin(-bottomItem->position() + highlightEnd - size(), -maxExtent), -minExtent);
else
- pos = qMax(qMin(bottomItem->position() - highlightStart, -maxExtent), -minExtent);
+ pos = qMax(qMin(bottomItem->position() - highlightEnd, -maxExtent), -minExtent);
} else {
QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
return;
@@ -1377,6 +1358,27 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
}
vTime = timeline.time();
}
+ } else if (currentItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange
+ && moveReason != QDeclarativeListViewPrivate::SetIndex) {
+ updateHighlight();
+ qreal pos = currentItem->itemPosition();
+ if (viewPos < pos + currentItem->itemSize() - highlightEnd)
+ viewPos = pos + currentItem->itemSize() - highlightEnd;
+ if (viewPos > pos - highlightStart)
+ viewPos = pos - highlightStart;
+ if (isRightToLeft())
+ viewPos = -viewPos-size();
+
+ timeline.reset(data.move);
+ if (viewPos != position()) {
+ if (fixupMode != Immediate) {
+ timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
+ data.fixingUp = true;
+ } else {
+ timeline.set(data.move, -viewPos);
+ }
+ }
+ vTime = timeline.time();
} else {
QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
}
@@ -1398,12 +1400,19 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
}
qreal maxDistance = 0;
qreal dataValue = isRightToLeft() ? -data.move.value()+size() : data.move.value();
+ qreal highlightStart = isRightToLeft() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart;
// -ve velocity means list is moving up/left
if (velocity > 0) {
if (data.move.value() < minExtent) {
- if (snapMode == QDeclarativeListView::SnapOneItem) {
- if (FxListItem *item = isRightToLeft() ? nextVisibleItem() : firstVisibleItem())
- maxDistance = qAbs(item->position() + dataValue);
+ if (snapMode == QDeclarativeListView::SnapOneItem && !hData.flicking && !vData.flicking) {
+ // if we've been dragged < averageSize/2 then bias towards the next item
+ qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal bias = dist < averageSize/2 ? averageSize/2 : 0;
+ if (isRightToLeft())
+ bias = -bias;
+ data.flickTarget = -snapPosAt(-(dataValue - highlightStart) - bias) + highlightStart;
+ maxDistance = qAbs(data.flickTarget - data.move.value());
+ velocity = maxVelocity;
} else {
maxDistance = qAbs(minExtent - data.move.value());
}
@@ -1412,9 +1421,15 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
data.flickTarget = minExtent;
} else {
if (data.move.value() > maxExtent) {
- if (snapMode == QDeclarativeListView::SnapOneItem) {
- if (FxListItem *item = isRightToLeft() ? firstVisibleItem() : nextVisibleItem())
- maxDistance = qAbs(item->position() + dataValue);
+ if (snapMode == QDeclarativeListView::SnapOneItem && !hData.flicking && !vData.flicking) {
+ // if we've been dragged < averageSize/2 then bias towards the next item
+ qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal bias = -dist < averageSize/2 ? averageSize/2 : 0;
+ if (isRightToLeft())
+ bias = -bias;
+ data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + bias) + highlightStart;
+ maxDistance = qAbs(data.flickTarget - data.move.value());
+ velocity = -maxVelocity;
} else {
maxDistance = qAbs(maxExtent - data.move.value());
}
@@ -1424,7 +1439,6 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
}
bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds;
- qreal highlightStart = isRightToLeft() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart;
if (maxDistance > 0 || overShoot) {
// These modes require the list to stop exactly on an item boundary.
@@ -1438,7 +1452,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
else
v = maxVelocity;
}
- if (!flickingHorizontally && !flickingVertically) {
+ if (!hData.flicking && !vData.flicking) {
// the initial flick - estimate boundary
qreal accel = deceleration;
qreal v2 = v * v;
@@ -1450,8 +1464,10 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (v > 0)
dist = -dist;
if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarativeListView::SnapOneItem) {
- qreal distTemp = isRightToLeft() ? -dist : dist;
- data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + distTemp) + highlightStart;
+ if (snapMode != QDeclarativeListView::SnapOneItem) {
+ qreal distTemp = isRightToLeft() ? -dist : dist;
+ data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + distTemp) + highlightStart;
+ }
data.flickTarget = isRightToLeft() ? -data.flickTarget+size() : data.flickTarget;
if (overShoot) {
if (data.flickTarget >= minExtent) {
@@ -1489,14 +1505,14 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
timeline.reset(data.move);
timeline.accel(data.move, v, accel, maxDistance + overshootDist);
timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
- if (!flickingHorizontally && q->xflick()) {
- flickingHorizontally = true;
+ if (!hData.flicking && q->xflick()) {
+ hData.flicking = true;
emit q->flickingChanged();
emit q->flickingHorizontallyChanged();
emit q->flickStarted();
}
- if (!flickingVertically && q->yflick()) {
- flickingVertically = true;
+ if (!vData.flicking && q->yflick()) {
+ vData.flicking = true;
emit q->flickingChanged();
emit q->flickingVerticallyChanged();
emit q->flickStarted();
@@ -1872,6 +1888,8 @@ void QDeclarativeListView::setCurrentIndex(int index)
if (index == d->currentIndex)
return;
if (isComponentComplete() && d->isValid()) {
+ if (d->layoutScheduled)
+ d->layout();
d->moveReason = QDeclarativeListViewPrivate::SetIndex;
d->updateCurrent(index);
} else if (d->currentIndex != index) {
@@ -2557,7 +2575,8 @@ bool QDeclarativeListView::event(QEvent *event)
{
Q_D(QDeclarativeListView);
if (event->type() == QEvent::User) {
- d->layout();
+ if (d->layoutScheduled)
+ d->layout();
return true;
}
@@ -2576,7 +2595,7 @@ void QDeclarativeListView::viewportMoved()
d->inViewportMoved = true;
d->lazyRelease = true;
refill();
- if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically)
+ if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving)
d->moveReason = QDeclarativeListViewPrivate::Mouse;
if (d->moveReason != QDeclarativeListViewPrivate::SetIndex) {
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
@@ -2610,7 +2629,7 @@ void QDeclarativeListView::viewportMoved()
}
}
- if ((d->flickingHorizontally || d->flickingVertically) && d->correctFlick && !d->inFlickCorrection) {
+ if ((d->hData.flicking || d->vData.flicking) && d->correctFlick && !d->inFlickCorrection) {
d->inFlickCorrection = true;
// Near an end and it seems that the extent has changed?
// Recalculate the flick so that we don't end up in an odd position.
diff --git a/src/gui/dialogs/qerrormessage.cpp b/src/gui/dialogs/qerrormessage.cpp
index 890e6ca6b7..0a6580afef 100644
--- a/src/gui/dialogs/qerrormessage.cpp
+++ b/src/gui/dialogs/qerrormessage.cpp
@@ -249,12 +249,20 @@ QErrorMessage::QErrorMessage(QWidget * parent)
d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
#endif
- grid->addWidget(d->icon, 0, 0, Qt::AlignTop);
+#ifdef Q_WS_S60
+ //In Symbian, messagebox icons are in LtR UIs on right. Thus, layout needs to switch icon and text columns.
+ const int preferredIconColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 1 : 0;
+ const int preferredTextColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 0 : 1;
+#else
+ const int preferredIconColumn = 0;
+ const int preferredTextColumn = 1;
+#endif
+ grid->addWidget(d->icon, 0, preferredIconColumn, Qt::AlignTop);
d->errors = new QErrorMessageTextView(this);
- grid->addWidget(d->errors, 0, 1);
+ grid->addWidget(d->errors, 0, preferredTextColumn);
d->again = new QCheckBox(this);
d->again->setChecked(true);
- grid->addWidget(d->again, 1, 1, Qt::AlignTop);
+ grid->addWidget(d->again, 1, preferredTextColumn, Qt::AlignTop);
d->ok = new QPushButton(this);
#ifdef QT_SOFTKEYS_ENABLED
d->okAction = new QAction(d->ok);
@@ -270,7 +278,7 @@ QErrorMessage::QErrorMessage(QWidget * parent)
connect(d->ok, SIGNAL(clicked()), this, SLOT(accept()));
d->ok->setFocus();
grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter);
- grid->setColumnStretch(1, 42);
+ grid->setColumnStretch(preferredTextColumn, 42);
grid->setRowStretch(0, 42);
d->retranslateStrings();
}
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
index 90ca080715..c3a10841d7 100644
--- a/src/gui/dialogs/qmessagebox.cpp
+++ b/src/gui/dialogs/qmessagebox.cpp
@@ -259,8 +259,15 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text)
QGridLayout *grid = new QGridLayout;
#ifndef Q_WS_MAC
- grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
- grid->addWidget(label, 0, 1, 1, 1);
+#ifdef Q_WS_S60
+ const int preferredIconColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 1 : 0;
+ const int preferredTextColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 0 : 1;
+#else
+ const int preferredIconColumn = 0;
+ const int preferredTextColumn = 1;
+#endif
+ grid->addWidget(iconLabel, 0, preferredIconColumn, 2, 1, Qt::AlignTop);
+ grid->addWidget(label, 0, preferredTextColumn, 1, 1);
// -- leave space for information label --
grid->addWidget(buttonBox, 2, 0, 1, 2);
#else
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index b47b4c8e55..de4575404a 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -141,6 +141,7 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme
{SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter},
{SE_TableItemPressed, QS60StyleEnums::SP_QsnFrGridCenterPressed},
{SE_ListItemPressed, QS60StyleEnums::SP_QsnFrListCenterPressed},
+ {SE_DialogBackground, QS60StyleEnums::SP_QsnFrPopupCenter},
};
static const int frameElementsCount =
@@ -263,6 +264,9 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter,
case SE_PopupBackground:
drawFrame(SF_PopupBackground, painter, rect, flags | SF_PointNorth);
break;
+ case SE_DialogBackground:
+ drawFrame(SF_DialogBackground, painter, rect, flags | SF_PointNorth);
+ break;
case SE_SettingsList:
drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth);
break;
@@ -2261,10 +2265,14 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)
&& QS60StylePrivate::equalToThemePalette(option->palette.window().texture().cacheKey(), QPalette::Window)) {
const bool comboMenu = qobject_cast<const QComboBoxListView *>(widget);
+ const bool menu = qobject_cast<const QMenu *>(widget);
// Add margin area to the background, to avoid background being cut for first and last item.
const int verticalMenuAdjustment = comboMenu ? QS60StylePrivate::pixelMetric(PM_MenuVMargin) : 0;
const QRect adjustedMenuRect = option->rect.adjusted(0, -verticalMenuAdjustment, 0, verticalMenuAdjustment);
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, adjustedMenuRect, flags);
+ if (comboMenu || menu)
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, adjustedMenuRect, flags);
+ else
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_DialogBackground, painter, adjustedMenuRect, flags);
} else {
commonStyleDraws = true;
}
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index de3cab77a5..2fa8c7fdea 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -541,6 +541,7 @@ public:
SE_DropArea,
SE_TableItemPressed,
SE_ListItemPressed,
+ SE_DialogBackground,
};
enum SkinFrameElements {
@@ -560,6 +561,7 @@ public:
SF_ButtonInactive,
SF_TableItemPressed,
SF_ListItemPressed,
+ SF_DialogBackground,
};
enum SkinElementFlag {
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 59d5da4ab0..913352a904 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -1160,6 +1160,10 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme
centerId.Set(KAknsIIDQsnFrPopupCenterSubmenu);
frameId.Set(KAknsIIDQsnFrPopupSub);
break;
+ case QS60StylePrivate::SF_DialogBackground:
+ centerId.Set(KAknsIIDQsnFrPopupCenter);
+ frameId.Set(KAknsIIDQsnFrPopup);
+ break;
case QS60StylePrivate::SF_SettingsList:
// Starting from S60_5_3, the root theme has been changed so that KAknsIIDQsnFrSetOpt is empty.
// Set the theme ID to None, to avoid theme server trying to draw the empty frame.
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp
new file mode 100644
index 0000000000..39ced2a9d0
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "abstracttool.h"
+
+#include "abstractviewinspector.h"
+
+namespace QmlJSDebugger {
+
+AbstractTool::AbstractTool(AbstractViewInspector *inspector) :
+ QObject(inspector),
+ m_inspector(inspector)
+{
+}
+
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h
new file mode 100644
index 0000000000..0a216bfa83
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTTOOL_H
+#define ABSTRACTTOOL_H
+
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+class QMouseEvent;
+class QKeyEvent;
+class QWheelEvent;
+QT_END_NAMESPACE
+
+namespace QmlJSDebugger {
+
+class AbstractViewInspector;
+
+class AbstractTool : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit AbstractTool(AbstractViewInspector *inspector);
+
+ AbstractViewInspector *inspector() const { return m_inspector; }
+
+ virtual void leaveEvent(QEvent *event) = 0;
+
+ virtual void mousePressEvent(QMouseEvent *event) = 0;
+ virtual void mouseMoveEvent(QMouseEvent *event) = 0;
+ virtual void mouseReleaseEvent(QMouseEvent *event) = 0;
+ virtual void mouseDoubleClickEvent(QMouseEvent *event) = 0;
+
+ virtual void hoverMoveEvent(QMouseEvent *event) = 0;
+ virtual void wheelEvent(QWheelEvent *event) = 0;
+
+ virtual void keyPressEvent(QKeyEvent *event) = 0;
+ virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
+
+private:
+ AbstractViewInspector *m_inspector;
+};
+
+} // namespace QmlJSDebugger
+
+#endif // ABSTRACTTOOL_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
new file mode 100644
index 0000000000..3323d54246
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
@@ -0,0 +1,611 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "abstractviewinspector.h"
+
+#include "abstracttool.h"
+#include "editor/qmltoolbar.h"
+#include "qdeclarativeinspectorprotocol.h"
+
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeComponent>
+#include <QtDeclarative/private/qdeclarativedebughelper_p.h>
+#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h"
+
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QMouseEvent>
+#include <QtCore/QSettings>
+
+static inline void initEditorResource() { Q_INIT_RESOURCE(editor); }
+
+namespace QmlJSDebugger {
+
+const char * const KEY_TOOLBOX_GEOMETRY = "toolBox/geometry";
+
+
+class ToolBox : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ToolBox(QWidget *parent = 0);
+ ~ToolBox();
+
+ QmlToolBar *toolBar() const { return m_toolBar; }
+
+private:
+ QSettings m_settings;
+ QmlToolBar *m_toolBar;
+};
+
+ToolBox::ToolBox(QWidget *parent)
+ : QWidget(parent, Qt::Tool)
+ , m_settings(QLatin1String("Nokia"), QLatin1String("QmlInspector"), this)
+ , m_toolBar(new QmlToolBar)
+{
+ setWindowFlags((windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::CustomizeWindowHint);
+ setWindowTitle(tr("Qt Quick Toolbox"));
+
+ QVBoxLayout *verticalLayout = new QVBoxLayout;
+ verticalLayout->setMargin(0);
+ verticalLayout->addWidget(m_toolBar);
+ setLayout(verticalLayout);
+
+ restoreGeometry(m_settings.value(QLatin1String(KEY_TOOLBOX_GEOMETRY)).toByteArray());
+}
+
+ToolBox::~ToolBox()
+{
+ m_settings.setValue(QLatin1String(KEY_TOOLBOX_GEOMETRY), saveGeometry());
+}
+
+
+AbstractViewInspector::AbstractViewInspector(QObject *parent) :
+ QObject(parent),
+ m_toolBox(0),
+ m_currentTool(0),
+ m_showAppOnTop(false),
+ m_designModeBehavior(false),
+ m_animationPaused(false),
+ m_slowDownFactor(1.0),
+ m_debugService(0)
+{
+ initEditorResource();
+
+ m_debugService = QDeclarativeInspectorService::instance();
+ connect(m_debugService, SIGNAL(gotMessage(QByteArray)),
+ this, SLOT(handleMessage(QByteArray)));
+}
+
+void AbstractViewInspector::createQmlObject(const QString &qml, QObject *parent,
+ const QStringList &importList,
+ const QString &filename)
+{
+ if (!parent)
+ return;
+
+ QString imports;
+ foreach (const QString &s, importList) {
+ imports += s;
+ imports += QLatin1Char('\n');
+ }
+
+ QDeclarativeContext *parentContext = declarativeEngine()->contextForObject(parent);
+ QDeclarativeComponent component(declarativeEngine());
+ QByteArray constructedQml = QString(imports + qml).toLatin1();
+
+ component.setData(constructedQml, QUrl::fromLocalFile(filename));
+ QObject *newObject = component.create(parentContext);
+ if (newObject)
+ reparentQmlObject(newObject, parent);
+}
+
+void AbstractViewInspector::clearComponentCache()
+{
+ declarativeEngine()->clearComponentCache();
+}
+
+void AbstractViewInspector::setDesignModeBehavior(bool value)
+{
+ if (m_designModeBehavior == value)
+ return;
+
+ m_designModeBehavior = value;
+ emit designModeBehaviorChanged(value);
+ sendDesignModeBehavior(value);
+}
+
+void AbstractViewInspector::setAnimationSpeed(qreal slowDownFactor)
+{
+ Q_ASSERT(slowDownFactor > 0);
+ if (m_slowDownFactor == slowDownFactor)
+ return;
+
+ animationSpeedChangeRequested(slowDownFactor);
+ sendAnimationSpeed(slowDownFactor);
+}
+
+void AbstractViewInspector::setAnimationPaused(bool paused)
+{
+ if (m_animationPaused == paused)
+ return;
+
+ animationPausedChangeRequested(paused);
+ sendAnimationPaused(paused);
+}
+
+void AbstractViewInspector::animationSpeedChangeRequested(qreal factor)
+{
+ if (m_slowDownFactor != factor) {
+ m_slowDownFactor = factor;
+ emit animationSpeedChanged(factor);
+ }
+
+ const float effectiveFactor = m_animationPaused ? 0 : factor;
+ QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
+}
+
+void AbstractViewInspector::animationPausedChangeRequested(bool paused)
+{
+ if (m_animationPaused != paused) {
+ m_animationPaused = paused;
+ emit animationPausedChanged(paused);
+ }
+
+ const float effectiveFactor = paused ? 0 : m_slowDownFactor;
+ QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
+}
+
+void AbstractViewInspector::setShowAppOnTop(bool appOnTop)
+{
+ if (viewWidget()) {
+ QWidget *window = viewWidget()->window();
+ Qt::WindowFlags flags = window->windowFlags();
+ if (appOnTop)
+ flags |= Qt::WindowStaysOnTopHint;
+ else
+ flags &= ~Qt::WindowStaysOnTopHint;
+
+ window->setWindowFlags(flags);
+ window->show();
+ }
+
+ m_showAppOnTop = appOnTop;
+ sendShowAppOnTop(appOnTop);
+
+ emit showAppOnTopChanged(appOnTop);
+}
+
+void AbstractViewInspector::setToolBoxVisible(bool visible)
+{
+#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
+ if (!m_toolBox && visible)
+ createToolBox();
+ if (m_toolBox)
+ m_toolBox->setVisible(visible);
+#else
+ Q_UNUSED(visible)
+#endif
+}
+
+void AbstractViewInspector::createToolBox()
+{
+ m_toolBox = new ToolBox(viewWidget());
+
+ QmlToolBar *toolBar = m_toolBox->toolBar();
+
+ QObject::connect(this, SIGNAL(selectedColorChanged(QColor)),
+ toolBar, SLOT(setColorBoxColor(QColor)));
+
+ QObject::connect(this, SIGNAL(designModeBehaviorChanged(bool)),
+ toolBar, SLOT(setDesignModeBehavior(bool)));
+
+ QObject::connect(toolBar, SIGNAL(designModeBehaviorChanged(bool)),
+ this, SLOT(setDesignModeBehavior(bool)));
+ QObject::connect(toolBar, SIGNAL(animationSpeedChanged(qreal)), this, SLOT(setAnimationSpeed(qreal)));
+ QObject::connect(toolBar, SIGNAL(animationPausedChanged(bool)), this, SLOT(setAnimationPaused(bool)));
+ QObject::connect(toolBar, SIGNAL(colorPickerSelected()), this, SLOT(changeToColorPickerTool()));
+ QObject::connect(toolBar, SIGNAL(zoomToolSelected()), this, SLOT(changeToZoomTool()));
+ QObject::connect(toolBar, SIGNAL(selectToolSelected()), this, SLOT(changeToSingleSelectTool()));
+ QObject::connect(toolBar, SIGNAL(marqueeSelectToolSelected()),
+ this, SLOT(changeToMarqueeSelectTool()));
+
+ QObject::connect(toolBar, SIGNAL(applyChangesFromQmlFileSelected()),
+ this, SLOT(applyChangesFromClient()));
+
+ QObject::connect(this, SIGNAL(animationSpeedChanged(qreal)), toolBar, SLOT(setAnimationSpeed(qreal)));
+ QObject::connect(this, SIGNAL(animationPausedChanged(bool)), toolBar, SLOT(setAnimationPaused(bool)));
+
+ QObject::connect(this, SIGNAL(selectToolActivated()), toolBar, SLOT(activateSelectTool()));
+
+ // disabled features
+ //connect(d->m_toolBar, SIGNAL(applyChangesToQmlFileSelected()), SLOT(applyChangesToClient()));
+ //connect(q, SIGNAL(resizeToolActivated()), d->m_toolBar, SLOT(activateSelectTool()));
+ //connect(q, SIGNAL(moveToolActivated()), d->m_toolBar, SLOT(activateSelectTool()));
+
+ QObject::connect(this, SIGNAL(colorPickerActivated()), toolBar, SLOT(activateColorPicker()));
+ QObject::connect(this, SIGNAL(zoomToolActivated()), toolBar, SLOT(activateZoom()));
+ QObject::connect(this, SIGNAL(marqueeSelectToolActivated()),
+ toolBar, SLOT(activateMarqueeSelectTool()));
+}
+
+void AbstractViewInspector::changeToColorPickerTool()
+{
+ changeTool(InspectorProtocol::ColorPickerTool);
+}
+
+void AbstractViewInspector::changeToZoomTool()
+{
+ changeTool(InspectorProtocol::ZoomTool);
+}
+
+void AbstractViewInspector::changeToSingleSelectTool()
+{
+ changeTool(InspectorProtocol::SelectTool);
+}
+
+void AbstractViewInspector::changeToMarqueeSelectTool()
+{
+ changeTool(InspectorProtocol::SelectMarqueeTool);
+}
+
+bool AbstractViewInspector::eventFilter(QObject *obj, QEvent *event)
+{
+ if (!designModeBehavior())
+ return QObject::eventFilter(obj, event);
+
+ switch (event->type()) {
+ case QEvent::Leave:
+ if (leaveEvent(event))
+ return true;
+ break;
+ case QEvent::MouseButtonPress:
+ if (mousePressEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ case QEvent::MouseMove:
+ if (mouseMoveEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ case QEvent::MouseButtonRelease:
+ if (mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ case QEvent::KeyPress:
+ if (keyPressEvent(static_cast<QKeyEvent*>(event)))
+ return true;
+ break;
+ case QEvent::KeyRelease:
+ if (keyReleaseEvent(static_cast<QKeyEvent*>(event)))
+ return true;
+ break;
+ case QEvent::MouseButtonDblClick:
+ if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ case QEvent::Wheel:
+ if (wheelEvent(static_cast<QWheelEvent*>(event)))
+ return true;
+ break;
+ default:
+ break;
+ }
+
+ return QObject::eventFilter(obj, event);
+}
+
+bool AbstractViewInspector::leaveEvent(QEvent *event)
+{
+ m_currentTool->leaveEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::mousePressEvent(QMouseEvent *event)
+{
+ m_currentTool->mousePressEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::mouseMoveEvent(QMouseEvent *event)
+{
+ if (event->buttons()) {
+ m_currentTool->mouseMoveEvent(event);
+ } else {
+ m_currentTool->hoverMoveEvent(event);
+ }
+ return true;
+}
+
+bool AbstractViewInspector::mouseReleaseEvent(QMouseEvent *event)
+{
+ m_currentTool->mouseReleaseEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::keyPressEvent(QKeyEvent *event)
+{
+ m_currentTool->keyPressEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::keyReleaseEvent(QKeyEvent *event)
+{
+ switch (event->key()) {
+ case Qt::Key_V:
+ changeTool(InspectorProtocol::SelectTool);
+ break;
+// disabled because multiselection does not do anything useful without design mode
+// case Qt::Key_M:
+// changeTool(InspectorProtocol::SelectMarqueeTool);
+// break;
+ case Qt::Key_I:
+ changeTool(InspectorProtocol::ColorPickerTool);
+ break;
+ case Qt::Key_Z:
+ changeTool(InspectorProtocol::ZoomTool);
+ break;
+ case Qt::Key_Space:
+ setAnimationPaused(!animationPaused());
+ break;
+ default:
+ break;
+ }
+
+ m_currentTool->keyReleaseEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ m_currentTool->mouseDoubleClickEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::wheelEvent(QWheelEvent *event)
+{
+ m_currentTool->wheelEvent(event);
+ return true;
+}
+
+void AbstractViewInspector::handleMessage(const QByteArray &message)
+{
+ QDataStream ds(message);
+
+ InspectorProtocol::Message type;
+ ds >> type;
+
+ switch (type) {
+ case InspectorProtocol::SetCurrentObjects: {
+ int itemCount = 0;
+ ds >> itemCount;
+
+ QList<QObject*> selectedObjects;
+ for (int i = 0; i < itemCount; ++i) {
+ int debugId = -1;
+ ds >> debugId;
+ if (QObject *obj = QDeclarativeDebugService::objectForId(debugId))
+ selectedObjects << obj;
+ }
+
+ changeCurrentObjects(selectedObjects);
+ break;
+ }
+ case InspectorProtocol::Reload: {
+ reloadView();
+ break;
+ }
+ case InspectorProtocol::SetAnimationSpeed: {
+ qreal speed;
+ ds >> speed;
+ animationSpeedChangeRequested(speed);
+ break;
+ }
+ case InspectorProtocol::SetAnimationPaused: {
+ bool paused;
+ ds >> paused;
+ animationPausedChangeRequested(paused);
+ break;
+ }
+ case InspectorProtocol::ChangeTool: {
+ InspectorProtocol::Tool tool;
+ ds >> tool;
+ changeTool(tool);
+ break;
+ }
+ case InspectorProtocol::SetDesignMode: {
+ bool inDesignMode;
+ ds >> inDesignMode;
+ setDesignModeBehavior(inDesignMode);
+ break;
+ }
+ case InspectorProtocol::ShowAppOnTop: {
+ bool showOnTop;
+ ds >> showOnTop;
+ setShowAppOnTop(showOnTop);
+ break;
+ }
+ case InspectorProtocol::CreateObject: {
+ QString qml;
+ int parentId;
+ QString filename;
+ QStringList imports;
+ ds >> qml >> parentId >> imports >> filename;
+ createQmlObject(qml, QDeclarativeDebugService::objectForId(parentId),
+ imports, filename);
+ break;
+ }
+ case InspectorProtocol::DestroyObject: {
+ int debugId;
+ ds >> debugId;
+ if (QObject *obj = QDeclarativeDebugService::objectForId(debugId))
+ obj->deleteLater();
+ break;
+ }
+ case InspectorProtocol::MoveObject: {
+ int debugId, newParent;
+ ds >> debugId >> newParent;
+ reparentQmlObject(QDeclarativeDebugService::objectForId(debugId),
+ QDeclarativeDebugService::objectForId(newParent));
+ break;
+ }
+ case InspectorProtocol::ObjectIdList: {
+ int itemCount;
+ ds >> itemCount;
+ m_stringIdForObjectId.clear();
+ for (int i = 0; i < itemCount; ++i) {
+ int itemDebugId;
+ QString itemIdString;
+ ds >> itemDebugId
+ >> itemIdString;
+
+ m_stringIdForObjectId.insert(itemDebugId, itemIdString);
+ }
+ break;
+ }
+ case InspectorProtocol::ClearComponentCache: {
+ clearComponentCache();
+ break;
+ }
+ default:
+ qWarning() << "Warning: Not handling message:" << type;
+ }
+}
+
+void AbstractViewInspector::sendDesignModeBehavior(bool inDesignMode)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << InspectorProtocol::SetDesignMode
+ << inDesignMode;
+
+ m_debugService->sendMessage(message);
+}
+
+void AbstractViewInspector::sendCurrentObjects(const QList<QObject*> &objects)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << InspectorProtocol::CurrentObjectsChanged
+ << objects.length();
+
+ foreach (QObject *object, objects) {
+ int id = QDeclarativeDebugService::idForObject(object);
+ ds << id;
+ }
+
+ m_debugService->sendMessage(message);
+}
+
+void AbstractViewInspector::sendCurrentTool(Constants::DesignTool toolId)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << InspectorProtocol::ToolChanged
+ << toolId;
+
+ m_debugService->sendMessage(message);
+}
+
+void AbstractViewInspector::sendAnimationSpeed(qreal slowDownFactor)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << InspectorProtocol::AnimationSpeedChanged
+ << slowDownFactor;
+
+ m_debugService->sendMessage(message);
+}
+
+void AbstractViewInspector::sendAnimationPaused(bool paused)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << InspectorProtocol::AnimationPausedChanged
+ << paused;
+
+ m_debugService->sendMessage(message);
+}
+
+void AbstractViewInspector::sendReloaded()
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << InspectorProtocol::Reloaded;
+
+ m_debugService->sendMessage(message);
+}
+
+void AbstractViewInspector::sendShowAppOnTop(bool showAppOnTop)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << InspectorProtocol::ShowAppOnTop << showAppOnTop;
+
+ m_debugService->sendMessage(message);
+}
+
+void AbstractViewInspector::sendColorChanged(const QColor &color)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << InspectorProtocol::ColorChanged
+ << color;
+
+ m_debugService->sendMessage(message);
+}
+
+QString AbstractViewInspector::idStringForObject(QObject *obj) const
+{
+ const int id = QDeclarativeDebugService::idForObject(obj);
+ return m_stringIdForObjectId.value(id);
+}
+
+} // namespace QmlJSDebugger
+
+#include "abstractviewinspector.moc"
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h
new file mode 100644
index 0000000000..7202bcca40
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTVIEWINSPECTOR_H
+#define ABSTRACTVIEWINSPECTOR_H
+
+#include <QtCore/QHash>
+#include <QtCore/QObject>
+#include <QtCore/QStringList>
+#include <QtGui/QColor>
+
+#include "qdeclarativeinspectorprotocol.h"
+#include "qmlinspectorconstants.h"
+
+QT_BEGIN_NAMESPACE
+class QDeclarativeEngine;
+class QDeclarativeInspectorService;
+class QKeyEvent;
+class QMouseEvent;
+class QWheelEvent;
+QT_END_NAMESPACE
+
+namespace QmlJSDebugger {
+
+class AbstractTool;
+class ToolBox;
+
+/*
+ * The common code between QSGView and QDeclarativeView inspectors lives here,
+ */
+class AbstractViewInspector : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit AbstractViewInspector(QObject *parent = 0);
+
+ virtual void changeCurrentObjects(const QList<QObject*> &objects) = 0;
+
+ virtual void reloadView() = 0;
+
+ void createQmlObject(const QString &qml, QObject *parent,
+ const QStringList &importList,
+ const QString &filename = QString());
+
+ virtual void reparentQmlObject(QObject *object, QObject *newParent) = 0;
+
+ virtual void changeTool(InspectorProtocol::Tool tool) = 0;
+
+ void clearComponentCache();
+
+ virtual QWidget *viewWidget() const = 0;
+ virtual QDeclarativeEngine *declarativeEngine() const = 0;
+
+
+ bool showAppOnTop() const { return m_showAppOnTop; }
+ bool designModeBehavior() const { return m_designModeBehavior; }
+
+ bool animationPaused() const { return m_animationPaused; }
+ qreal slowDownFactor() const { return m_slowDownFactor; }
+
+ void sendCurrentObjects(const QList<QObject*> &);
+ void sendAnimationSpeed(qreal slowDownFactor);
+ void sendAnimationPaused(bool paused);
+ void sendCurrentTool(Constants::DesignTool toolId);
+ void sendReloaded();
+ void sendShowAppOnTop(bool showAppOnTop);
+
+ QString idStringForObject(QObject *obj) const;
+
+public slots:
+ void sendDesignModeBehavior(bool inDesignMode);
+ void sendColorChanged(const QColor &color);
+
+ void changeToColorPickerTool();
+ void changeToZoomTool();
+ void changeToSingleSelectTool();
+ void changeToMarqueeSelectTool();
+
+ virtual void setDesignModeBehavior(bool value);
+
+ void setShowAppOnTop(bool appOnTop);
+
+ void setAnimationSpeed(qreal factor);
+ void setAnimationPaused(bool paused);
+
+signals:
+ void designModeBehaviorChanged(bool inDesignMode);
+ void showAppOnTopChanged(bool showAppOnTop);
+ void reloadRequested();
+ void marqueeSelectToolActivated();
+ void selectToolActivated();
+ void zoomToolActivated();
+ void colorPickerActivated();
+ void selectedColorChanged(const QColor &color);
+
+ void animationSpeedChanged(qreal factor);
+ void animationPausedChanged(bool paused);
+
+protected:
+ bool eventFilter(QObject *, QEvent *);
+
+ virtual bool leaveEvent(QEvent *);
+ virtual bool mousePressEvent(QMouseEvent *event);
+ virtual bool mouseMoveEvent(QMouseEvent *event);
+ virtual bool mouseReleaseEvent(QMouseEvent *event);
+ virtual bool keyPressEvent(QKeyEvent *event);
+ virtual bool keyReleaseEvent(QKeyEvent *keyEvent);
+ virtual bool mouseDoubleClickEvent(QMouseEvent *event);
+ virtual bool wheelEvent(QWheelEvent *event);
+
+ AbstractTool *currentTool() const { return m_currentTool; }
+ void setCurrentTool(AbstractTool *tool) { m_currentTool = tool; }
+
+private slots:
+ void handleMessage(const QByteArray &message);
+
+private:
+ void animationSpeedChangeRequested(qreal factor);
+ void animationPausedChangeRequested(bool paused);
+
+ void setToolBoxVisible(bool visible);
+ void createToolBox();
+
+ ToolBox *m_toolBox;
+ AbstractTool *m_currentTool;
+
+ bool m_showAppOnTop;
+ bool m_designModeBehavior;
+
+ bool m_animationPaused;
+ qreal m_slowDownFactor;
+
+ QHash<int, QString> m_stringIdForObjectId;
+ QDeclarativeInspectorService *m_debugService;
+};
+
+} // namespace QmlJSDebugger
+
+#endif // ABSTRACTVIEWINSPECTOR_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp
index 36e6ba0ad7..dce147c842 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "abstractliveedittool_p.h"
-#include "../qdeclarativeviewinspector_p_p.h"
+#include "abstractliveedittool.h"
+#include "../qdeclarativeviewinspector_p.h"
#include <QDeclarativeEngine>
@@ -48,10 +48,10 @@
#include <QGraphicsItem>
#include <QDeclarativeItem>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView)
- : QObject(editorView), m_inspector(editorView)
+ : AbstractTool(editorView)
{
}
@@ -62,12 +62,12 @@ AbstractLiveEditTool::~AbstractLiveEditTool()
QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const
{
- return m_inspector;
+ return static_cast<QDeclarativeViewInspector*>(AbstractTool::inspector());
}
QDeclarativeView *AbstractLiveEditTool::view() const
{
- return m_inspector->declarativeView();
+ return inspector()->declarativeView();
}
QGraphicsScene* AbstractLiveEditTool::scene() const
@@ -175,7 +175,7 @@ QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject);
if (declarativeItem) {
- objectStringId = m_inspector->idStringForObject(declarativeItem);
+ objectStringId = inspector()->idStringForObject(declarativeItem);
}
if (!objectStringId.isEmpty()) {
@@ -192,4 +192,5 @@ QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
return constructedName;
}
-QT_END_NAMESPACE
+
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h
index 17eb6ea6ce..04b5f4e46e 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h
@@ -43,7 +43,7 @@
#define ABSTRACTLIVEEDITTOOL_H
#include <QtCore/QList>
-#include <QtCore/QObject>
+#include "../abstracttool.h"
QT_BEGIN_NAMESPACE
class QMouseEvent;
@@ -56,15 +56,11 @@ class QWheelEvent;
class QDeclarativeView;
QT_END_NAMESPACE
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class QDeclarativeViewInspector;
-class AbstractLiveEditTool : public QObject
+class AbstractLiveEditTool : public AbstractTool
{
Q_OBJECT
public:
@@ -72,16 +68,8 @@ public:
virtual ~AbstractLiveEditTool();
- virtual void mousePressEvent(QMouseEvent *event) = 0;
- virtual void mouseMoveEvent(QMouseEvent *event) = 0;
- virtual void mouseReleaseEvent(QMouseEvent *event) = 0;
- virtual void mouseDoubleClickEvent(QMouseEvent *event) = 0;
+ void leaveEvent(QEvent *) {}
- virtual void hoverMoveEvent(QMouseEvent *event) = 0;
- virtual void wheelEvent(QWheelEvent *event) = 0;
-
- virtual void keyPressEvent(QKeyEvent *event) = 0;
- virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
virtual void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList) = 0;
virtual void clear() = 0;
@@ -108,12 +96,9 @@ protected:
QGraphicsScene *scene() const;
private:
- QDeclarativeViewInspector *m_inspector;
QList<QGraphicsItem*> m_itemList;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+}
#endif // ABSTRACTLIVEEDITTOOL_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp
index 3f95005f45..da9f442026 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp
@@ -39,10 +39,10 @@
**
****************************************************************************/
-#include "boundingrecthighlighter_p.h"
+#include "boundingrecthighlighter.h"
-#include "../qdeclarativeviewinspector_p.h"
-#include "../qmlinspectorconstants_p.h"
+#include "../qdeclarativeviewinspector.h"
+#include "../qmlinspectorconstants.h"
#include <QtGui/QGraphicsPolygonItem>
@@ -50,7 +50,7 @@
#include <QtCore/QObject>
#include <QtCore/QDebug>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem,
QObject *parent)
@@ -236,4 +236,5 @@ void BoundingRectHighlighter::refresh()
highlightAll();
}
-QT_END_NAMESPACE
+
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.h
index e2928f7f72..81883ee0aa 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.h
@@ -42,7 +42,7 @@
#ifndef BOUNDINGRECTHIGHLIGHTER_H
#define BOUNDINGRECTHIGHLIGHTER_H
-#include "livelayeritem_p.h"
+#include "livelayeritem.h"
#include <QtCore/QObject>
#include <QtCore/QWeakPointer>
@@ -53,11 +53,7 @@ QT_FORWARD_DECLARE_CLASS(QWidget)
QT_FORWARD_DECLARE_CLASS(QStyleOptionGraphicsItem)
QT_FORWARD_DECLARE_CLASS(QTimer)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class QDeclarativeViewInspector;
class BoundingBox;
@@ -114,8 +110,6 @@ public:
int type() const;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // BOUNDINGRECTHIGHLIGHTER_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp
index bdae3d8298..72e1380146 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp
@@ -39,9 +39,9 @@
**
****************************************************************************/
-#include "colorpickertool_p.h"
+#include "colorpickertool.h"
-#include "../qdeclarativeviewinspector_p.h"
+#include "../qdeclarativeviewinspector.h"
#include <QtGui/QMouseEvent>
#include <QtGui/QKeyEvent>
@@ -51,7 +51,7 @@
#include <QtGui/QApplication>
#include <QtGui/QPalette>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) :
AbstractLiveEditTool(view)
@@ -61,56 +61,23 @@ ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) :
ColorPickerTool::~ColorPickerTool()
{
-
}
-void ColorPickerTool::mousePressEvent(QMouseEvent * /*event*/)
-{
-}
-
-void ColorPickerTool::mouseMoveEvent(QMouseEvent *event)
+void ColorPickerTool::mousePressEvent(QMouseEvent *event)
{
pickColor(event->pos());
}
-void ColorPickerTool::mouseReleaseEvent(QMouseEvent *event)
+void ColorPickerTool::mouseMoveEvent(QMouseEvent *event)
{
pickColor(event->pos());
}
-void ColorPickerTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
-{
-}
-
-
-void ColorPickerTool::hoverMoveEvent(QMouseEvent * /*event*/)
-{
-}
-
-void ColorPickerTool::keyPressEvent(QKeyEvent * /*event*/)
-{
-}
-
-void ColorPickerTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
-{
-}
-void ColorPickerTool::wheelEvent(QWheelEvent * /*event*/)
-{
-}
-
-void ColorPickerTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
-{
-}
-
void ColorPickerTool::clear()
{
view()->setCursor(Qt::CrossCursor);
}
-void ColorPickerTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
-{
-}
-
void ColorPickerTool::pickColor(const QPoint &pos)
{
QRgb fillColor = view()->backgroundBrush().color().rgb();
@@ -128,4 +95,4 @@ void ColorPickerTool::pickColor(const QPoint &pos)
emit selectedColorChanged(m_selectedColor);
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h
index 580c175c5b..a28ffea63a 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h
@@ -42,17 +42,13 @@
#ifndef COLORPICKERTOOL_H
#define COLORPICKERTOOL_H
-#include "abstractliveedittool_p.h"
+#include "abstractliveedittool.h"
#include <QtGui/QColor>
QT_FORWARD_DECLARE_CLASS(QPoint)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class ColorPickerTool : public AbstractLiveEditTool
{
@@ -64,17 +60,17 @@ public:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *) {}
+ void mouseDoubleClickEvent(QMouseEvent *) {}
- void hoverMoveEvent(QMouseEvent *event);
+ void hoverMoveEvent(QMouseEvent *) {}
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *keyEvent);
+ void keyPressEvent(QKeyEvent *) {}
+ void keyReleaseEvent(QKeyEvent *) {}
- void wheelEvent(QWheelEvent *event);
+ void wheelEvent(QWheelEvent *) {}
- void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
+ void itemsAboutToRemoved(const QList<QGraphicsItem*> &) {}
void clear();
@@ -82,8 +78,7 @@ signals:
void selectedColorChanged(const QColor &color);
protected:
-
- void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
+ void selectedItemsChanged(const QList<QGraphicsItem*> &) {}
private:
void pickColor(const QPoint &pos);
@@ -92,8 +87,6 @@ private:
QColor m_selectedColor;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // COLORPICKERTOOL_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp
index c28893ef6a..fb7118fbc2 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp
@@ -39,13 +39,13 @@
**
****************************************************************************/
-#include "livelayeritem_p.h"
+#include "livelayeritem.h"
-#include "../qmlinspectorconstants_p.h"
+#include "../qmlinspectorconstants.h"
#include <QGraphicsScene>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
LiveLayerItem::LiveLayerItem(QGraphicsScene* scene)
: QGraphicsObject()
@@ -89,4 +89,4 @@ QList<QGraphicsItem*> LiveLayerItem::findAllChildItems(const QGraphicsItem *item
return itemList;
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h
index da622e18a0..4dccc0b6f3 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h
@@ -44,11 +44,7 @@
#include <QtGui/QGraphicsObject>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class LiveLayerItem : public QGraphicsObject
{
@@ -66,8 +62,6 @@ protected:
QList<QGraphicsItem*> findAllChildItems(const QGraphicsItem *item) const;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+}
#endif // LIVELAYERITEM_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp
index d32847d5bd..b08682a396 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp
@@ -39,15 +39,15 @@
**
****************************************************************************/
-#include "liverubberbandselectionmanipulator_p.h"
+#include "liverubberbandselectionmanipulator.h"
-#include "../qdeclarativeviewinspector_p_p.h"
+#include "../qdeclarativeviewinspector_p.h"
#include <QtGui/QGraphicsItem>
#include <QtCore/QDebug>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
QDeclarativeViewInspector *editorView)
@@ -162,4 +162,4 @@ bool LiveRubberBandSelectionManipulator::isActive() const
return m_isActive;
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.h
index 9abcb2b70c..aa15a34730 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.h
@@ -42,17 +42,13 @@
#ifndef RUBBERBANDSELECTIONMANIPULATOR_H
#define RUBBERBANDSELECTIONMANIPULATOR_H
-#include "liveselectionrectangle_p.h"
+#include "liveselectionrectangle.h"
#include <QtCore/QPointF>
QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class QDeclarativeViewInspector;
@@ -95,8 +91,6 @@ private:
bool m_isActive;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+}
#endif // RUBBERBANDSELECTIONMANIPULATOR_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp
index 4450fc5110..c57bc0e26c 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp
@@ -39,17 +39,17 @@
**
****************************************************************************/
-#include "liveselectionindicator_p.h"
+#include "liveselectionindicator.h"
-#include "../qdeclarativeviewinspector_p_p.h"
-#include "../qmlinspectorconstants_p.h"
+#include "../qdeclarativeviewinspector_p.h"
+#include "../qmlinspectorconstants.h"
#include <QtGui/QGraphicsRectItem>
#include <QtGui/QGraphicsObject>
#include <QtGui/QGraphicsScene>
#include <QtGui/QPen>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector,
QGraphicsObject *layerItem)
@@ -114,4 +114,5 @@ void LiveSelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject>
}
}
-QT_END_NAMESPACE
+} //namespace QmlJSDebugger
+
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.h
index fa6eb306b9..7b8cc12e62 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.h
@@ -52,11 +52,7 @@ class QGraphicsItem;
class QPolygonF;
QT_END_NAMESPACE
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class QDeclarativeViewInspector;
@@ -79,8 +75,6 @@ private:
QDeclarativeViewInspector *m_view;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+}
#endif // LIVESELECTIONINDICATOR_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp
index 267079a2a1..4e144589b7 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp
@@ -39,9 +39,9 @@
**
****************************************************************************/
-#include "liveselectionrectangle_p.h"
+#include "liveselectionrectangle.h"
-#include "../qmlinspectorconstants_p.h"
+#include "../qmlinspectorconstants.h"
#include <QtGui/QPen>
#include <QtGui/QGraphicsRectItem>
@@ -52,7 +52,7 @@
#include <cmath>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
class SelectionRectShape : public QGraphicsRectItem
{
@@ -110,4 +110,4 @@ void LiveSelectionRectangle::setRect(const QPointF &firstPoint,
m_controlShape->setRect(rect);
}
-QT_END_NAMESPACE
+}
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.h
index 5da9fb884d..730cca52d5 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.h
@@ -49,11 +49,7 @@ QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem)
QT_FORWARD_DECLARE_CLASS(QPointF)
QT_FORWARD_DECLARE_CLASS(QRectF)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class LiveSelectionRectangle
{
@@ -76,8 +72,6 @@ private:
QWeakPointer<QGraphicsObject> m_layerItem;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // LIVESELECTIONRECTANGLE_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp
index c55cba3966..6085d8131a 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp
@@ -39,10 +39,10 @@
**
****************************************************************************/
-#include "liveselectiontool_p.h"
-#include "livelayeritem_p.h"
+#include "liveselectiontool.h"
+#include "livelayeritem.h"
-#include "../qdeclarativeviewinspector_p_p.h"
+#include "../qdeclarativeviewinspector_p.h"
#include <QtGui/QApplication>
#include <QtGui/QWheelEvent>
@@ -57,7 +57,7 @@
#include <QtCore/QDebug>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
LiveSelectionTool::LiveSelectionTool(QDeclarativeViewInspector *editorView) :
AbstractLiveEditTool(editorView),
@@ -132,7 +132,7 @@ void LiveSelectionTool::mousePressEvent(QMouseEvent *event)
}
}
-void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
+void LiveSelectionTool::createContextMenu(const QList<QGraphicsItem*> &itemList, QPoint globalPos)
{
QMenu contextMenu;
connect(&contextMenu, SIGNAL(hovered(QAction*)),
@@ -143,7 +143,6 @@ void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint
contextMenu.addAction(tr("Items"));
contextMenu.addSeparator();
int shortcutKey = Qt::Key_1;
- bool addKeySequence = true;
int i = 0;
foreach (QGraphicsItem * const item, itemList) {
@@ -158,12 +157,11 @@ void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint
}
elementAction->setData(i);
- if (addKeySequence)
- elementAction->setShortcut(QKeySequence(shortcutKey));
- shortcutKey++;
- if (shortcutKey > Qt::Key_9)
- addKeySequence = false;
+ if (shortcutKey <= Qt::Key_9) {
+ elementAction->setShortcut(QKeySequence(shortcutKey));
+ shortcutKey++;
+ }
++i;
}
@@ -305,10 +303,6 @@ void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event)
}
}
-void LiveSelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
-{
-}
-
void LiveSelectionTool::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
@@ -323,11 +317,6 @@ void LiveSelectionTool::keyPressEvent(QKeyEvent *event)
}
}
-void LiveSelectionTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
-{
-
-}
-
void LiveSelectionTool::wheelEvent(QWheelEvent *event)
{
if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode)
@@ -372,10 +361,6 @@ void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems)
m_selectOnlyContentItems = selectOnlyContentItems;
}
-void LiveSelectionTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
-{
-}
-
void LiveSelectionTool::clear()
{
view()->setCursor(Qt::ArrowCursor);
@@ -435,4 +420,4 @@ void LiveSelectionTool::selectUnderPoint(QMouseEvent *event)
m_singleSelectionManipulator.end(event->pos());
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h
index 7562f3e854..2c281cda3c 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h
@@ -42,10 +42,10 @@
#ifndef LIVESELECTIONTOOL_H
#define LIVESELECTIONTOOL_H
-#include "abstractliveedittool_p.h"
-#include "liverubberbandselectionmanipulator_p.h"
-#include "livesingleselectionmanipulator_p.h"
-#include "liveselectionindicator_p.h"
+#include "abstractliveedittool.h"
+#include "liverubberbandselectionmanipulator.h"
+#include "livesingleselectionmanipulator.h"
+#include "liveselectionindicator.h"
#include <QtCore/QList>
#include <QtCore/QTime>
@@ -55,11 +55,7 @@ QT_FORWARD_DECLARE_CLASS(QMouseEvent)
QT_FORWARD_DECLARE_CLASS(QKeyEvent)
QT_FORWARD_DECLARE_CLASS(QAction)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class LiveSelectionTool : public AbstractLiveEditTool
{
@@ -72,13 +68,13 @@ public:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *) {}
void hoverMoveEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *keyEvent);
+ void keyReleaseEvent(QKeyEvent *) {}
void wheelEvent(QWheelEvent *event);
- void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
+ void itemsAboutToRemoved(const QList<QGraphicsItem*> &) {}
// QVariant itemChange(const QList<QGraphicsItem*> &itemList,
// QGraphicsItem::GraphicsItemChange change,
// const QVariant &value );
@@ -101,7 +97,7 @@ private slots:
void repaintBoundingRects();
private:
- void createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos);
+ void createContextMenu(const QList<QGraphicsItem*> &itemList, QPoint globalPos);
LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers);
bool alreadySelected(const QList<QGraphicsItem*> &itemList) const;
@@ -119,8 +115,6 @@ private:
QList<QGraphicsItem*> m_contextMenuItemList;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // LIVESELECTIONTOOL_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp
index ee9843bedc..34c1469208 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp
@@ -39,13 +39,13 @@
**
****************************************************************************/
-#include "livesingleselectionmanipulator_p.h"
+#include "livesingleselectionmanipulator.h"
-#include "../qdeclarativeviewinspector_p_p.h"
+#include "../qdeclarativeviewinspector_p.h"
#include <QtDebug>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView)
: m_editorView(editorView),
@@ -148,4 +148,4 @@ QPointF LiveSingleSelectionManipulator::beginPoint() const
return m_beginPoint;
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.h
index 40b5fc0208..ac65711a91 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.h
@@ -47,11 +47,7 @@
QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class QDeclarativeViewInspector;
@@ -88,8 +84,6 @@ private:
bool m_isActive;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // LIVESINGLESELECTIONMANIPULATOR_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp
index 0a7267434a..4e0e37518a 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "qmltoolbar_p.h"
-#include "toolbarcolorbox_p.h"
+#include "qmltoolbar.h"
+#include "toolbarcolorbox.h"
#include <QtGui/QLabel>
#include <QtGui/QIcon>
@@ -49,7 +49,7 @@
#include <QtCore/QDebug>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
QmlToolBar::QmlToolBar(QWidget *parent)
: QToolBar(parent)
@@ -325,4 +325,4 @@ void QmlToolBar::activateToQml()
emit applyChangesToQmlFileSelected();
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h
index 0401804184..2abf1660f0 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h
@@ -45,15 +45,11 @@
#include <QtGui/QToolBar>
#include <QtGui/QIcon>
-#include "../qmlinspectorconstants_p.h"
+#include "../qmlinspectorconstants.h"
QT_FORWARD_DECLARE_CLASS(QActionGroup)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class ToolBarColorBox;
@@ -131,8 +127,6 @@ private:
Ui *ui;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+}
#endif // QMLTOOLBAR_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp
index 2ed3179856..5d99886601 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp
@@ -39,14 +39,14 @@
**
****************************************************************************/
-#include "subcomponentmasklayeritem_p.h"
+#include "subcomponentmasklayeritem.h"
-#include "../qmlinspectorconstants_p.h"
-#include "../qdeclarativeviewinspector_p.h"
+#include "../qmlinspectorconstants.h"
+#include "../qdeclarativeviewinspector.h"
#include <QtGui/QPolygonF>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector,
QGraphicsItem *parentItem) :
@@ -127,4 +127,4 @@ QGraphicsItem *SubcomponentMaskLayerItem::currentItem() const
return m_currentItem;
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h
index 07ce881851..e41d70a61b 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h
@@ -44,11 +44,7 @@
#include <QtGui/QGraphicsPolygonItem>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class QDeclarativeViewInspector;
@@ -70,8 +66,6 @@ private:
QRectF m_itemPolyRect;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // SUBCOMPONENTMASKLAYERITEM_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp
index 154ddf2c6f..091466284f 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp
@@ -39,9 +39,9 @@
**
****************************************************************************/
-#include "toolbarcolorbox_p.h"
+#include "toolbarcolorbox.h"
-#include "../qmlinspectorconstants_p.h"
+#include "../qmlinspectorconstants.h"
#include <QtGui/QPixmap>
#include <QtGui/QPainter>
@@ -56,7 +56,7 @@
#include <QtCore/QMimeData>
#include <QtCore/QDebug>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
ToolBarColorBox::ToolBarColorBox(QWidget *parent) :
QLabel(parent)
@@ -131,4 +131,4 @@ void ToolBarColorBox::copyColorToClipboard()
clipboard->setText(m_color.name());
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h
index c3e064c21e..8ef75a4114 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h
@@ -49,11 +49,7 @@
QT_FORWARD_DECLARE_CLASS(QContextMenuEvent)
QT_FORWARD_DECLARE_CLASS(QAction)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class ToolBarColorBox : public QLabel
{
@@ -80,8 +76,6 @@ private:
QColor m_color;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // TOOLBARCOLORBOX_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp
index 969c9d55d7..c8ade825a2 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp
@@ -39,9 +39,9 @@
**
****************************************************************************/
-#include "zoomtool_p.h"
+#include "zoomtool.h"
-#include "../qdeclarativeviewinspector_p_p.h"
+#include "../qdeclarativeviewinspector_p.h"
#include <QtGui/QMouseEvent>
#include <QtGui/QWheelEvent>
@@ -52,7 +52,7 @@
#include <QtCore/QRectF>
#include <QtCore/QDebug>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
ZoomTool::ZoomTool(QDeclarativeViewInspector *view) :
AbstractLiveEditTool(view),
@@ -242,19 +242,11 @@ void ZoomTool::keyReleaseEvent(QKeyEvent *event)
}
-void ZoomTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
-{
-}
-
void ZoomTool::clear()
{
view()->setCursor(Qt::ArrowCursor);
}
-void ZoomTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
-{
-}
-
void ZoomTool::scaleView(const QPointF &centerPos)
{
@@ -333,4 +325,4 @@ qreal ZoomTool::nextZoomScale(ZoomDirection direction) const
return 1.0f;
}
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h
index 14fa4d5390..de935591cb 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h
@@ -42,16 +42,12 @@
#ifndef ZOOMTOOL_H
#define ZOOMTOOL_H
-#include "abstractliveedittool_p.h"
-#include "liverubberbandselectionmanipulator_p.h"
+#include "abstractliveedittool.h"
+#include "liverubberbandselectionmanipulator.h"
QT_FORWARD_DECLARE_CLASS(QAction)
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class ZoomTool : public AbstractLiveEditTool
{
@@ -77,12 +73,12 @@ public:
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *keyEvent);
- void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
+ void itemsAboutToRemoved(const QList<QGraphicsItem*> &) {}
void clear();
protected:
- void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
+ void selectedItemsChanged(const QList<QGraphicsItem*> &) {}
private slots:
void zoomTo100();
@@ -106,8 +102,6 @@ private:
qreal m_currentScale;
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // ZOOMTOOL_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp
index a266eb90b5..932f911c55 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp
@@ -46,7 +46,7 @@
#include <QtCore/qplugin.h>
#include <QtDeclarative/private/qdeclarativeinspectorservice_p.h>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
QDeclarativeInspectorPlugin::QDeclarativeInspectorPlugin() :
m_inspector(0)
@@ -75,7 +75,6 @@ void QDeclarativeInspectorPlugin::deactivate()
delete m_inspector;
}
-Q_EXPORT_PLUGIN2(declarativeinspector, QDeclarativeInspectorPlugin)
-
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
+Q_EXPORT_PLUGIN2(declarativeinspector, QmlJSDebugger::QDeclarativeInspectorPlugin)
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h
index 3e28643eff..542925366c 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h
@@ -45,9 +45,9 @@
#include <QtCore/QPointer>
#include <QtDeclarative/private/qdeclarativeinspectorinterface_p.h>
-QT_BEGIN_NAMESPACE
+namespace QmlJSDebugger {
-class QDeclarativeViewInspector;
+class AbstractViewInspector;
class QDeclarativeInspectorPlugin : public QObject, public QDeclarativeInspectorInterface
{
@@ -63,9 +63,9 @@ public:
void deactivate();
private:
- QPointer<QDeclarativeViewInspector> m_inspector;
+ QPointer<AbstractViewInspector> m_inspector;
};
-QT_END_NAMESPACE
+} // namespace QmlJSDebugger
#endif // QDECLARATIVEINSPECTORPLUGIN_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h
index 2878bc188a..082abeb9bd 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h
@@ -47,11 +47,7 @@
#include <QtCore/QMetaEnum>
#include <QtCore/QObject>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
+namespace QmlJSDebugger {
class InspectorProtocol : public QObject
{
@@ -136,8 +132,6 @@ inline QDebug operator<< (QDebug dbg, InspectorProtocol::Tool tool)
return dbg;
}
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // QDECLARATIVEINSPECTORPROTOCOL_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
index 19bfdaa3b5..3351df9d0b 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
@@ -39,84 +39,24 @@
**
****************************************************************************/
-#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h"
-#include "QtDeclarative/private/qdeclarativedebughelper_p.h"
-
+#include "qdeclarativeviewinspector.h"
#include "qdeclarativeviewinspector_p.h"
-#include "qdeclarativeviewinspector_p_p.h"
-#include "qdeclarativeinspectorprotocol.h"
-#include "editor/liveselectiontool_p.h"
-#include "editor/zoomtool_p.h"
-#include "editor/colorpickertool_p.h"
-#include "editor/livelayeritem_p.h"
-#include "editor/boundingrecthighlighter_p.h"
-#include "editor/qmltoolbar_p.h"
+#include "editor/liveselectiontool.h"
+#include "editor/zoomtool.h"
+#include "editor/colorpickertool.h"
+#include "editor/livelayeritem.h"
+#include "editor/boundingrecthighlighter.h"
#include <QtDeclarative/QDeclarativeItem>
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QtDeclarative/QDeclarativeContext>
-#include <QtDeclarative/QDeclarativeExpression>
#include <QtGui/QWidget>
-#include <QtGui/QVBoxLayout>
#include <QtGui/QMouseEvent>
#include <QtGui/QGraphicsObject>
-#include <QtGui/QApplication>
-#include <QtCore/QSettings>
-
-static inline void initEditorResource() { Q_INIT_RESOURCE(editor); }
-
-QT_BEGIN_NAMESPACE
-
-const char * const KEY_TOOLBOX_GEOMETRY = "toolBox/geometry";
-
-const int SceneChangeUpdateInterval = 5000;
-
-
-class ToolBox : public QWidget
-{
- Q_OBJECT
-
-public:
- ToolBox(QWidget *parent = 0);
- ~ToolBox();
-
- QmlToolBar *toolBar() const { return m_toolBar; }
-
-private:
- QSettings m_settings;
- QmlToolBar *m_toolBar;
-};
-
-ToolBox::ToolBox(QWidget *parent)
- : QWidget(parent, Qt::Tool)
- , m_settings(QLatin1String("Nokia"), QLatin1String("QmlInspector"), this)
- , m_toolBar(new QmlToolBar)
-{
- setWindowFlags((windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::CustomizeWindowHint);
- setWindowTitle(tr("Qt Quick Toolbox"));
-
- QVBoxLayout *verticalLayout = new QVBoxLayout;
- verticalLayout->setMargin(0);
- verticalLayout->addWidget(m_toolBar);
- setLayout(verticalLayout);
-
- restoreGeometry(m_settings.value(QLatin1String(KEY_TOOLBOX_GEOMETRY)).toByteArray());
-}
-
-ToolBox::~ToolBox()
-{
- m_settings.setValue(QLatin1String(KEY_TOOLBOX_GEOMETRY), saveGeometry());
-}
+namespace QmlJSDebugger {
QDeclarativeViewInspectorPrivate::QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *q) :
- q(q),
- designModeBehavior(false),
- showAppOnTop(false),
- animationPaused(false),
- slowDownFactor(1.0f),
- toolBox(0)
+ q(q)
{
}
@@ -126,28 +66,22 @@ QDeclarativeViewInspectorPrivate::~QDeclarativeViewInspectorPrivate()
QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view,
QObject *parent) :
- QObject(parent),
+ AbstractViewInspector(parent),
data(new QDeclarativeViewInspectorPrivate(this))
{
- initEditorResource();
-
data->view = view;
data->manipulatorLayer = new LiveLayerItem(view->scene());
data->selectionTool = new LiveSelectionTool(this);
data->zoomTool = new ZoomTool(this);
data->colorPickerTool = new ColorPickerTool(this);
data->boundingRectHighlighter = new BoundingRectHighlighter(this);
- data->currentTool = data->selectionTool;
+ setCurrentTool(data->selectionTool);
// to capture ChildRemoved event when viewport changes
data->view->installEventFilter(this);
data->setViewport(data->view->viewport());
- data->debugService = QDeclarativeInspectorService::instance();
- connect(data->debugService, SIGNAL(gotMessage(QByteArray)),
- this, SLOT(handleMessage(QByteArray)));
-
connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)),
data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
@@ -156,29 +90,62 @@ QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view,
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
this, SLOT(sendColorChanged(QColor)));
- data->_q_changeToSingleSelectTool();
+ changeTool(InspectorProtocol::SelectTool);
}
QDeclarativeViewInspector::~QDeclarativeViewInspector()
{
}
-void QDeclarativeViewInspectorPrivate::_q_setToolBoxVisible(bool visible)
+void QDeclarativeViewInspector::changeCurrentObjects(const QList<QObject*> &objects)
{
-#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
- if (!toolBox && visible)
- createToolBox();
- if (toolBox)
- toolBox->setVisible(visible);
-#else
- Q_UNUSED(visible)
-#endif
+ QList<QGraphicsItem*> items;
+ QList<QGraphicsObject*> gfxObjects;
+ foreach (QObject *obj, objects) {
+ if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
+ items << declarativeItem;
+ gfxObjects << declarativeItem;
+ }
+ }
+ if (designModeBehavior()) {
+ data->setSelectedItemsForTools(items);
+ data->clearHighlight();
+ data->highlight(gfxObjects);
+ }
}
-void QDeclarativeViewInspectorPrivate::_q_reloadView()
+void QDeclarativeViewInspector::reloadView()
{
- clearHighlight();
- emit q->reloadRequested();
+ data->clearHighlight();
+ emit reloadRequested();
+}
+
+void QDeclarativeViewInspector::changeTool(InspectorProtocol::Tool tool)
+{
+ switch (tool) {
+ case InspectorProtocol::ColorPickerTool:
+ data->changeToColorPickerTool();
+ break;
+ case InspectorProtocol::SelectMarqueeTool:
+ data->changeToMarqueeSelectTool();
+ break;
+ case InspectorProtocol::SelectTool:
+ data->changeToSingleSelectTool();
+ break;
+ case InspectorProtocol::ZoomTool:
+ data->changeToZoomTool();
+ break;
+ }
+}
+
+AbstractLiveEditTool *QDeclarativeViewInspector::currentTool() const
+{
+ return static_cast<AbstractLiveEditTool*>(AbstractViewInspector::currentTool());
+}
+
+QDeclarativeEngine *QDeclarativeViewInspector::declarativeEngine() const
+{
+ return data->view->engine();
}
void QDeclarativeViewInspectorPrivate::setViewport(QWidget *widget)
@@ -215,174 +182,28 @@ bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event)
return QObject::eventFilter(obj, event);
}
- // Event from viewport
- switch (event->type()) {
- case QEvent::Leave: {
- if (leaveEvent(event))
- return true;
- break;
- }
- case QEvent::MouseButtonPress: {
- if (mousePressEvent(static_cast<QMouseEvent*>(event)))
- return true;
- break;
- }
- case QEvent::MouseMove: {
- if (mouseMoveEvent(static_cast<QMouseEvent*>(event)))
- return true;
- break;
- }
- case QEvent::MouseButtonRelease: {
- if (mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
- return true;
- break;
- }
- case QEvent::KeyPress: {
- if (keyPressEvent(static_cast<QKeyEvent*>(event)))
- return true;
- break;
- }
- case QEvent::KeyRelease: {
- if (keyReleaseEvent(static_cast<QKeyEvent*>(event)))
- return true;
- break;
- }
- case QEvent::MouseButtonDblClick: {
- if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event)))
- return true;
- break;
- }
- case QEvent::Wheel: {
- if (wheelEvent(static_cast<QWheelEvent*>(event)))
- return true;
- break;
- }
- default: {
- break;
- }
- } //switch
-
- // standard event processing
- return QObject::eventFilter(obj, event);
+ return AbstractViewInspector::eventFilter(obj, event);
}
-bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/)
+bool QDeclarativeViewInspector::leaveEvent(QEvent *event)
{
- if (!data->designModeBehavior)
- return false;
data->clearHighlight();
- return true;
-}
-
-bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event)
-{
- if (!data->designModeBehavior)
- return false;
- data->cursorPos = event->pos();
- data->currentTool->mousePressEvent(event);
- return true;
+ return AbstractViewInspector::leaveEvent(event);
}
bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event)
{
- if (!data->designModeBehavior) {
- data->clearEditorItems();
- return false;
- }
- data->cursorPos = event->pos();
-
QList<QGraphicsItem*> selItems = data->selectableItems(event->pos());
if (!selItems.isEmpty()) {
- declarativeView()->setToolTip(data->currentTool->titleForItem(selItems.first()));
+ declarativeView()->setToolTip(currentTool()->titleForItem(selItems.first()));
} else {
declarativeView()->setToolTip(QString());
}
- if (event->buttons()) {
- data->currentTool->mouseMoveEvent(event);
- } else {
- data->currentTool->hoverMoveEvent(event);
- }
- return true;
-}
-
-bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event)
-{
- if (!data->designModeBehavior)
- return false;
-
- data->cursorPos = event->pos();
- data->currentTool->mouseReleaseEvent(event);
- return true;
-}
-
-bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event)
-{
- if (!data->designModeBehavior)
- return false;
-
- data->currentTool->keyPressEvent(event);
- return true;
-}
-
-bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event)
-{
- if (!data->designModeBehavior)
- return false;
-
- switch (event->key()) {
- case Qt::Key_V:
- data->_q_changeToSingleSelectTool();
- break;
-// disabled because multiselection does not do anything useful without design mode
-// case Qt::Key_M:
-// data->_q_changeToMarqueeSelectTool();
-// break;
- case Qt::Key_I:
- data->_q_changeToColorPickerTool();
- break;
- case Qt::Key_Z:
- data->_q_changeToZoomTool();
- break;
- case Qt::Key_Space:
- setAnimationPaused(!data->animationPaused);
- break;
- default:
- break;
- }
- data->currentTool->keyReleaseEvent(event);
- return true;
+ return AbstractViewInspector::mouseMoveEvent(event);
}
-void QDeclarativeViewInspectorPrivate::_q_createQmlObject(const QString &qml, QObject *parent,
- const QStringList &importList,
- const QString &filename)
-{
- if (!parent)
- return;
-
- QString imports;
- foreach (const QString &s, importList) {
- imports += s;
- imports += QLatin1Char('\n');
- }
-
- QDeclarativeContext *parentContext = view->engine()->contextForObject(parent);
- QDeclarativeComponent component(view->engine(), q);
- QByteArray constructedQml = QString(imports + qml).toLatin1();
-
- component.setData(constructedQml, QUrl::fromLocalFile(filename));
- QObject *newObject = component.create(parentContext);
- if (newObject) {
- newObject->setParent(parent);
- QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent);
- QDeclarativeItem *newItem = qobject_cast<QDeclarativeItem*>(newObject);
- if (parentItem && newItem)
- newItem->setParentItem(parentItem);
- }
-}
-
-void QDeclarativeViewInspectorPrivate::_q_reparentQmlObject(QObject *object, QObject *newParent)
+void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent)
{
if (!newParent)
return;
@@ -394,11 +215,6 @@ void QDeclarativeViewInspectorPrivate::_q_reparentQmlObject(QObject *object, QOb
item->setParentItem(newParentItem);
}
-void QDeclarativeViewInspectorPrivate::_q_clearComponentCache()
-{
- view->engine()->clearComponentCache();
-}
-
void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj)
{
QList<QGraphicsItem*> items = selectedItems();
@@ -407,80 +223,6 @@ void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj)
setSelectedItems(items);
}
-bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/)
-{
- if (!data->designModeBehavior)
- return false;
-
- return true;
-}
-
-bool QDeclarativeViewInspector::wheelEvent(QWheelEvent *event)
-{
- if (!data->designModeBehavior)
- return false;
- data->currentTool->wheelEvent(event);
- return true;
-}
-
-void QDeclarativeViewInspector::setDesignModeBehavior(bool value)
-{
- emit designModeBehaviorChanged(value);
-
- if (data->toolBox)
- data->toolBox->toolBar()->setDesignModeBehavior(value);
- sendDesignModeBehavior(value);
-
- data->designModeBehavior = value;
-
- if (!data->designModeBehavior)
- data->clearEditorItems();
-}
-
-bool QDeclarativeViewInspector::designModeBehavior()
-{
- return data->designModeBehavior;
-}
-
-bool QDeclarativeViewInspector::showAppOnTop() const
-{
- return data->showAppOnTop;
-}
-
-void QDeclarativeViewInspector::setShowAppOnTop(bool appOnTop)
-{
- if (data->view) {
- QWidget *window = data->view->window();
- Qt::WindowFlags flags = window->windowFlags();
- if (appOnTop)
- flags |= Qt::WindowStaysOnTopHint;
- else
- flags &= ~Qt::WindowStaysOnTopHint;
-
- window->setWindowFlags(flags);
- window->show();
- }
-
- data->showAppOnTop = appOnTop;
- sendShowAppOnTop(appOnTop);
-
- emit showAppOnTopChanged(appOnTop);
-}
-
-void QDeclarativeViewInspectorPrivate::changeTool(Constants::DesignTool tool,
- Constants::ToolFlags /*flags*/)
-{
- switch (tool) {
- case Constants::SelectionToolMode:
- _q_changeToSingleSelectTool();
- break;
- case Constants::NoTool:
- default:
- currentTool = 0;
- break;
- }
-}
-
void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList<QGraphicsItem *> &items)
{
foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) {
@@ -503,7 +245,7 @@ void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList<QGra
}
}
- currentTool->updateSelectedItems();
+ q->currentTool()->updateSelectedItems();
}
void QDeclarativeViewInspectorPrivate::setSelectedItems(const QList<QGraphicsItem *> &items)
@@ -542,7 +284,7 @@ QList<QGraphicsItem *> QDeclarativeViewInspector::selectedItems() const
return data->selectedItems();
}
-QDeclarativeView *QDeclarativeViewInspector::declarativeView()
+QDeclarativeView *QDeclarativeViewInspector::declarativeView() const
{
return data->view;
}
@@ -591,9 +333,8 @@ QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(
return filterForSelection(itemlist);
}
-void QDeclarativeViewInspectorPrivate::_q_changeToSingleSelectTool()
+void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool()
{
- currentToolMode = Constants::SelectionToolMode;
selectionTool->setRubberbandSelectionMode(false);
changeToSelectTool();
@@ -604,97 +345,55 @@ void QDeclarativeViewInspectorPrivate::_q_changeToSingleSelectTool()
void QDeclarativeViewInspectorPrivate::changeToSelectTool()
{
- if (currentTool == selectionTool)
+ if (q->currentTool() == selectionTool)
return;
- currentTool->clear();
- currentTool = selectionTool;
- currentTool->clear();
- currentTool->updateSelectedItems();
+ q->currentTool()->clear();
+ q->setCurrentTool(selectionTool);
+ q->currentTool()->clear();
+ q->currentTool()->updateSelectedItems();
}
-void QDeclarativeViewInspectorPrivate::_q_changeToMarqueeSelectTool()
+void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool()
{
changeToSelectTool();
- currentToolMode = Constants::MarqueeSelectionToolMode;
selectionTool->setRubberbandSelectionMode(true);
emit q->marqueeSelectToolActivated();
q->sendCurrentTool(Constants::MarqueeSelectionToolMode);
}
-void QDeclarativeViewInspectorPrivate::_q_changeToZoomTool()
+void QDeclarativeViewInspectorPrivate::changeToZoomTool()
{
- currentToolMode = Constants::ZoomMode;
- currentTool->clear();
- currentTool = zoomTool;
- currentTool->clear();
+ q->currentTool()->clear();
+ q->setCurrentTool(zoomTool);
+ q->currentTool()->clear();
emit q->zoomToolActivated();
q->sendCurrentTool(Constants::ZoomMode);
}
-void QDeclarativeViewInspectorPrivate::_q_changeToColorPickerTool()
+void QDeclarativeViewInspectorPrivate::changeToColorPickerTool()
{
- if (currentTool == colorPickerTool)
+ if (q->currentTool() == colorPickerTool)
return;
- currentToolMode = Constants::ColorPickerMode;
- currentTool->clear();
- currentTool = colorPickerTool;
- currentTool->clear();
+ q->currentTool()->clear();
+ q->setCurrentTool(colorPickerTool);
+ q->currentTool()->clear();
emit q->colorPickerActivated();
q->sendCurrentTool(Constants::ColorPickerMode);
}
-void QDeclarativeViewInspector::setAnimationSpeed(qreal slowDownFactor)
-{
- Q_ASSERT(slowDownFactor > 0);
- if (data->slowDownFactor == slowDownFactor)
- return;
-
- animationSpeedChangeRequested(slowDownFactor);
- sendAnimationSpeed(slowDownFactor);
-}
-
-void QDeclarativeViewInspector::setAnimationPaused(bool paused)
-{
- if (data->animationPaused == paused)
- return;
-
- animationPausedChangeRequested(paused);
- sendAnimationPaused(paused);
-}
-
-void QDeclarativeViewInspector::animationSpeedChangeRequested(qreal factor)
-{
- if (data->slowDownFactor != factor) {
- data->slowDownFactor = factor;
- emit animationSpeedChanged(factor);
- }
-
- const float effectiveFactor = data->animationPaused ? 0 : factor;
- QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
-}
-
-void QDeclarativeViewInspector::animationPausedChangeRequested(bool paused)
-{
- if (data->animationPaused != paused) {
- data->animationPaused = paused;
- emit animationPausedChanged(paused);
- }
- const float effectiveFactor = paused ? 0 : data->slowDownFactor;
- QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
-}
-
-
-void QDeclarativeViewInspectorPrivate::_q_applyChangesFromClient()
+static bool isEditorItem(QGraphicsItem *item)
{
+ return (item->type() == Constants::EditorItemType
+ || item->type() == Constants::ResizeHandleItemType
+ || item->data(Constants::EditorItemDataKey).toBool());
}
-
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::filterForSelection(
QList<QGraphicsItem*> &itemlist) const
{
@@ -706,36 +405,12 @@ QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::filterForSelection(
return itemlist;
}
-bool QDeclarativeViewInspectorPrivate::isEditorItem(QGraphicsItem *item) const
-{
- return (item->type() == Constants::EditorItemType
- || item->type() == Constants::ResizeHandleItemType
- || item->data(Constants::EditorItemDataKey).toBool());
-}
-
void QDeclarativeViewInspectorPrivate::_q_onStatusChanged(QDeclarativeView::Status status)
{
if (status == QDeclarativeView::Ready)
q->sendReloaded();
}
-void QDeclarativeViewInspectorPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
-{
- QList<QGraphicsItem*> items;
- QList<QGraphicsObject*> gfxObjects;
- foreach (QObject *obj, objects) {
- if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
- items << declarativeItem;
- gfxObjects << declarativeItem;
- }
- }
- if (designModeBehavior) {
- setSelectedItemsForTools(items);
- clearHighlight();
- highlight(gfxObjects);
- }
-}
-
// adjusts bounding boxes on edges of screen to be visible
QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
{
@@ -758,264 +433,4 @@ QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundin
return boundingRect;
}
-void QDeclarativeViewInspectorPrivate::createToolBox()
-{
- toolBox = new ToolBox(q->declarativeView());
-
- QmlToolBar *toolBar = toolBox->toolBar();
-
- QObject::connect(q, SIGNAL(selectedColorChanged(QColor)),
- toolBar, SLOT(setColorBoxColor(QColor)));
-
- QObject::connect(q, SIGNAL(designModeBehaviorChanged(bool)),
- toolBar, SLOT(setDesignModeBehavior(bool)));
-
- QObject::connect(toolBar, SIGNAL(designModeBehaviorChanged(bool)),
- q, SLOT(setDesignModeBehavior(bool)));
- QObject::connect(toolBar, SIGNAL(animationSpeedChanged(qreal)), q, SLOT(setAnimationSpeed(qreal)));
- QObject::connect(toolBar, SIGNAL(animationPausedChanged(bool)), q, SLOT(setAnimationPaused(bool)));
- QObject::connect(toolBar, SIGNAL(colorPickerSelected()), this, SLOT(_q_changeToColorPickerTool()));
- QObject::connect(toolBar, SIGNAL(zoomToolSelected()), this, SLOT(_q_changeToZoomTool()));
- QObject::connect(toolBar, SIGNAL(selectToolSelected()), this, SLOT(_q_changeToSingleSelectTool()));
- QObject::connect(toolBar, SIGNAL(marqueeSelectToolSelected()),
- this, SLOT(_q_changeToMarqueeSelectTool()));
-
- QObject::connect(toolBar, SIGNAL(applyChangesFromQmlFileSelected()),
- this, SLOT(_q_applyChangesFromClient()));
-
- QObject::connect(q, SIGNAL(animationSpeedChanged(qreal)), toolBar, SLOT(setAnimationSpeed(qreal)));
- QObject::connect(q, SIGNAL(animationPausedChanged(bool)), toolBar, SLOT(setAnimationPaused(bool)));
-
- QObject::connect(q, SIGNAL(selectToolActivated()), toolBar, SLOT(activateSelectTool()));
-
- // disabled features
- //connect(d->m_toolBar, SIGNAL(applyChangesToQmlFileSelected()), SLOT(applyChangesToClient()));
- //connect(q, SIGNAL(resizeToolActivated()), d->m_toolBar, SLOT(activateSelectTool()));
- //connect(q, SIGNAL(moveToolActivated()), d->m_toolBar, SLOT(activateSelectTool()));
-
- QObject::connect(q, SIGNAL(colorPickerActivated()), toolBar, SLOT(activateColorPicker()));
- QObject::connect(q, SIGNAL(zoomToolActivated()), toolBar, SLOT(activateZoom()));
- QObject::connect(q, SIGNAL(marqueeSelectToolActivated()),
- toolBar, SLOT(activateMarqueeSelectTool()));
-}
-
-void QDeclarativeViewInspector::handleMessage(const QByteArray &message)
-{
- QDataStream ds(message);
-
- InspectorProtocol::Message type;
- ds >> type;
-
- switch (type) {
- case InspectorProtocol::SetCurrentObjects: {
- int itemCount = 0;
- ds >> itemCount;
-
- QList<QObject*> selectedObjects;
- for (int i = 0; i < itemCount; ++i) {
- int debugId = -1;
- ds >> debugId;
- if (QObject *obj = QDeclarativeDebugService::objectForId(debugId))
- selectedObjects << obj;
- }
-
- data->_q_onCurrentObjectsChanged(selectedObjects);
- break;
- }
- case InspectorProtocol::Reload: {
- data->_q_reloadView();
- break;
- }
- case InspectorProtocol::SetAnimationSpeed: {
- qreal speed;
- ds >> speed;
- animationSpeedChangeRequested(speed);
- break;
- }
- case InspectorProtocol::SetAnimationPaused: {
- bool paused;
- ds >> paused;
- animationPausedChangeRequested(paused);
- break;
- }
- case InspectorProtocol::ChangeTool: {
- InspectorProtocol::Tool tool;
- ds >> tool;
- switch (tool) {
- case InspectorProtocol::ColorPickerTool:
- data->_q_changeToColorPickerTool();
- break;
- case InspectorProtocol::SelectTool:
- data->_q_changeToSingleSelectTool();
- break;
- case InspectorProtocol::SelectMarqueeTool:
- data->_q_changeToMarqueeSelectTool();
- break;
- case InspectorProtocol::ZoomTool:
- data->_q_changeToZoomTool();
- break;
- default:
- qWarning() << "Warning: Unhandled tool:" << tool;
- }
- break;
- }
- case InspectorProtocol::SetDesignMode: {
- bool inDesignMode;
- ds >> inDesignMode;
- setDesignModeBehavior(inDesignMode);
- break;
- }
- case InspectorProtocol::ShowAppOnTop: {
- bool showOnTop;
- ds >> showOnTop;
- setShowAppOnTop(showOnTop);
- break;
- }
- case InspectorProtocol::CreateObject: {
- QString qml;
- int parentId;
- QString filename;
- QStringList imports;
- ds >> qml >> parentId >> imports >> filename;
- data->_q_createQmlObject(qml, QDeclarativeDebugService::objectForId(parentId),
- imports, filename);
- break;
- }
- case InspectorProtocol::DestroyObject: {
- int debugId;
- ds >> debugId;
- if (QObject* obj = QDeclarativeDebugService::objectForId(debugId))
- obj->deleteLater();
- break;
- }
- case InspectorProtocol::MoveObject: {
- int debugId, newParent;
- ds >> debugId >> newParent;
- data->_q_reparentQmlObject(QDeclarativeDebugService::objectForId(debugId),
- QDeclarativeDebugService::objectForId(newParent));
- break;
- }
- case InspectorProtocol::ObjectIdList: {
- int itemCount;
- ds >> itemCount;
- data->stringIdForObjectId.clear();
- for (int i = 0; i < itemCount; ++i) {
- int itemDebugId;
- QString itemIdString;
- ds >> itemDebugId
- >> itemIdString;
-
- data->stringIdForObjectId.insert(itemDebugId, itemIdString);
- }
- break;
- }
- case InspectorProtocol::ClearComponentCache: {
- data->_q_clearComponentCache();
- break;
- }
- default:
- qWarning() << "Warning: Not handling message:" << type;
- }
-}
-
-void QDeclarativeViewInspector::sendDesignModeBehavior(bool inDesignMode)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::SetDesignMode
- << inDesignMode;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendCurrentObjects(const QList<QObject*> &objects)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::CurrentObjectsChanged
- << objects.length();
-
- foreach (QObject *object, objects) {
- int id = QDeclarativeDebugService::idForObject(object);
- ds << id;
- }
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendCurrentTool(Constants::DesignTool toolId)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::ToolChanged
- << toolId;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendAnimationSpeed(qreal slowDownFactor)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::AnimationSpeedChanged
- << slowDownFactor;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendAnimationPaused(bool paused)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::AnimationPausedChanged
- << paused;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendReloaded()
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::Reloaded;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendShowAppOnTop(bool showAppOnTop)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::ShowAppOnTop << showAppOnTop;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendColorChanged(const QColor &color)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::ColorChanged
- << color;
-
- data->debugService->sendMessage(message);
-}
-
-QString QDeclarativeViewInspector::idStringForObject(QObject *obj) const
-{
- int id = QDeclarativeDebugService::idForObject(obj);
- QString idString = data->stringIdForObjectId.value(id, QString());
- return idString;
-}
-
-QT_END_NAMESPACE
-
-#include "qdeclarativeviewinspector.moc"
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h
new file mode 100644
index 0000000000..c77cd2c522
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVIEWINSPECTOR_H
+#define QDECLARATIVEVIEWINSPECTOR_H
+
+#include <private/qdeclarativeglobal_p.h>
+
+#include "qmlinspectorconstants.h"
+#include "abstractviewinspector.h"
+
+#include <QtCore/QScopedPointer>
+#include <QtDeclarative/QDeclarativeView>
+
+namespace QmlJSDebugger {
+
+class AbstractLiveEditTool;
+class QDeclarativeViewInspectorPrivate;
+
+class QDeclarativeViewInspector : public AbstractViewInspector
+{
+ Q_OBJECT
+
+public:
+ explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0);
+ ~QDeclarativeViewInspector();
+
+ // AbstractViewInspector
+ void changeCurrentObjects(const QList<QObject*> &objects);
+ void reloadView();
+ void reparentQmlObject(QObject *object, QObject *newParent);
+ void changeTool(InspectorProtocol::Tool tool);
+ QWidget *viewWidget() const { return declarativeView(); }
+ QDeclarativeEngine *declarativeEngine() const;
+
+ void setSelectedItems(QList<QGraphicsItem *> items);
+ QList<QGraphicsItem *> selectedItems() const;
+
+ QDeclarativeView *declarativeView() const;
+
+ QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+
+ bool leaveEvent(QEvent *);
+ bool mouseMoveEvent(QMouseEvent *event);
+
+ AbstractLiveEditTool *currentTool() const;
+
+private:
+ Q_DISABLE_COPY(QDeclarativeViewInspector)
+
+ inline QDeclarativeViewInspectorPrivate *d_func() { return data.data(); }
+ QScopedPointer<QDeclarativeViewInspectorPrivate> data;
+ friend class QDeclarativeViewInspectorPrivate;
+ friend class AbstractLiveEditTool;
+};
+
+} // namespace QmlJSDebugger
+
+#endif // QDECLARATIVEVIEWINSPECTOR_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h
index 4efa093fb1..bfa857cf41 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h
@@ -42,106 +42,76 @@
#ifndef QDECLARATIVEVIEWINSPECTOR_P_H
#define QDECLARATIVEVIEWINSPECTOR_P_H
-#include <private/qdeclarativeglobal_p.h>
-#include "qmlinspectorconstants_p.h"
+#include "qdeclarativeviewinspector.h"
-#include <QtCore/QScopedPointer>
-#include <QtDeclarative/QDeclarativeView>
+#include <QtCore/QWeakPointer>
+#include <QtCore/QPointF>
-QT_FORWARD_DECLARE_CLASS(QDeclarativeItem)
-QT_FORWARD_DECLARE_CLASS(QMouseEvent)
-QT_FORWARD_DECLARE_CLASS(QToolBar)
+#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h"
-QT_BEGIN_HEADER
+namespace QmlJSDebugger {
-QT_BEGIN_NAMESPACE
+class QDeclarativeViewInspector;
+class LiveSelectionTool;
+class ZoomTool;
+class ColorPickerTool;
+class LiveLayerItem;
+class BoundingRectHighlighter;
+class AbstractLiveEditTool;
-QT_MODULE(Declarative)
-
-class QDeclarativeViewInspectorPrivate;
-
-class QDeclarativeViewInspector : public QObject
+class QDeclarativeViewInspectorPrivate : public QObject
{
Q_OBJECT
-
public:
- explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0);
- ~QDeclarativeViewInspector();
-
- void setSelectedItems(QList<QGraphicsItem *> items);
- QList<QGraphicsItem *> selectedItems() const;
-
- QDeclarativeView *declarativeView();
-
- QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
+ QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *);
+ ~QDeclarativeViewInspectorPrivate();
- bool showAppOnTop() const;
+ QDeclarativeView *view;
+ QDeclarativeViewInspector *q;
+ QWeakPointer<QWidget> viewport;
- void sendDesignModeBehavior(bool inDesignMode);
- void sendCurrentObjects(const QList<QObject*> &);
- void sendAnimationSpeed(qreal slowDownFactor);
- void sendAnimationPaused(bool paused);
- void sendCurrentTool(Constants::DesignTool toolId);
- void sendReloaded();
- void sendShowAppOnTop(bool showAppOnTop);
+ QList<QWeakPointer<QGraphicsObject> > currentSelection;
- QString idStringForObject(QObject *obj) const;
+ LiveSelectionTool *selectionTool;
+ ZoomTool *zoomTool;
+ ColorPickerTool *colorPickerTool;
+ LiveLayerItem *manipulatorLayer;
-public Q_SLOTS:
- void sendColorChanged(const QColor &color);
+ BoundingRectHighlighter *boundingRectHighlighter;
- void setDesignModeBehavior(bool value);
- bool designModeBehavior();
+ void setViewport(QWidget *widget);
- void setShowAppOnTop(bool appOnTop);
+ void clearEditorItems();
+ void changeToSelectTool();
+ QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
- void setAnimationSpeed(qreal factor);
- void setAnimationPaused(bool paused);
+ QList<QGraphicsItem*> selectableItems(const QPoint &pos) const;
+ QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
+ QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
-Q_SIGNALS:
- void designModeBehaviorChanged(bool inDesignMode);
- void showAppOnTopChanged(bool showAppOnTop);
- void reloadRequested();
- void marqueeSelectToolActivated();
- void selectToolActivated();
- void zoomToolActivated();
- void colorPickerActivated();
- void selectedColorChanged(const QColor &color);
-
- void animationSpeedChanged(qreal factor);
- void animationPausedChanged(bool paused);
-
-protected:
- bool eventFilter(QObject *obj, QEvent *event);
-
- bool leaveEvent(QEvent *);
- bool mousePressEvent(QMouseEvent *event);
- bool mouseMoveEvent(QMouseEvent *event);
- bool mouseReleaseEvent(QMouseEvent *event);
- bool keyPressEvent(QKeyEvent *event);
- bool keyReleaseEvent(QKeyEvent *keyEvent);
- bool mouseDoubleClickEvent(QMouseEvent *event);
- bool wheelEvent(QWheelEvent *event);
+ void setSelectedItemsForTools(const QList<QGraphicsItem *> &items);
+ void setSelectedItems(const QList<QGraphicsItem *> &items);
+ QList<QGraphicsItem *> selectedItems() const;
- void setSelectedItemsForTools(QList<QGraphicsItem *> items);
+ void clearHighlight();
+ void highlight(const QList<QGraphicsObject *> &item);
+ inline void highlight(QGraphicsObject *item)
+ { highlight(QList<QGraphicsObject*>() << item); }
-private slots:
- void handleMessage(const QByteArray &message);
+ void changeToSingleSelectTool();
+ void changeToMarqueeSelectTool();
+ void changeToZoomTool();
+ void changeToColorPickerTool();
- void animationSpeedChangeRequested(qreal factor);
- void animationPausedChangeRequested(bool paused);
+public slots:
+ void _q_onStatusChanged(QDeclarativeView::Status status);
-private:
- Q_DISABLE_COPY(QDeclarativeViewInspector)
+ void _q_removeFromSelection(QObject *);
- inline QDeclarativeViewInspectorPrivate *d_func() { return data.data(); }
- QScopedPointer<QDeclarativeViewInspectorPrivate> data;
- friend class QDeclarativeViewInspectorPrivate;
- friend class AbstractLiveEditTool;
+public:
+ static QDeclarativeViewInspectorPrivate *get(QDeclarativeViewInspector *v) { return v->d_func(); }
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // QDECLARATIVEVIEWINSPECTOR_P_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h
deleted file mode 100644
index 11cbe0f447..0000000000
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEVIEWINSPECTOR_P_P_H
-#define QDECLARATIVEVIEWINSPECTOR_P_P_H
-
-#include "qdeclarativeviewinspector_p.h"
-
-#include <QtCore/QWeakPointer>
-#include <QtCore/QPointF>
-
-#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeViewInspector;
-class LiveSelectionTool;
-class ZoomTool;
-class ColorPickerTool;
-class LiveLayerItem;
-class BoundingRectHighlighter;
-class ToolBox;
-class AbstractLiveEditTool;
-
-class QDeclarativeViewInspectorPrivate : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *);
- ~QDeclarativeViewInspectorPrivate();
-
- QDeclarativeView *view;
- QDeclarativeViewInspector *q;
- QDeclarativeInspectorService *debugService;
- QWeakPointer<QWidget> viewport;
- QHash<int, QString> stringIdForObjectId;
-
- QPointF cursorPos;
- QList<QWeakPointer<QGraphicsObject> > currentSelection;
-
- Constants::DesignTool currentToolMode;
- AbstractLiveEditTool *currentTool;
-
- LiveSelectionTool *selectionTool;
- ZoomTool *zoomTool;
- ColorPickerTool *colorPickerTool;
- LiveLayerItem *manipulatorLayer;
-
- BoundingRectHighlighter *boundingRectHighlighter;
-
- bool designModeBehavior;
- bool showAppOnTop;
-
- bool animationPaused;
- qreal slowDownFactor;
-
- ToolBox *toolBox;
-
- void setViewport(QWidget *widget);
-
- void clearEditorItems();
- void createToolBox();
- void changeToSelectTool();
- QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
-
- QList<QGraphicsItem*> selectableItems(const QPoint &pos) const;
- QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
- QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
-
- 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(const QList<QGraphicsObject *> &item);
- inline void highlight(QGraphicsObject *item)
- { highlight(QList<QGraphicsObject*>() << item); }
-
- bool isEditorItem(QGraphicsItem *item) const;
-
-public slots:
- void _q_setToolBoxVisible(bool visible);
-
- void _q_reloadView();
- void _q_onStatusChanged(QDeclarativeView::Status status);
- void _q_onCurrentObjectsChanged(QList<QObject*> objects);
- void _q_applyChangesFromClient();
- void _q_createQmlObject(const QString &qml, QObject *parent,
- const QStringList &imports, const QString &filename = QString());
- void _q_reparentQmlObject(QObject *, QObject *);
-
- void _q_changeToSingleSelectTool();
- void _q_changeToMarqueeSelectTool();
- void _q_changeToZoomTool();
- void _q_changeToColorPickerTool();
- void _q_clearComponentCache();
- void _q_removeFromSelection(QObject *);
-
-public:
- static QDeclarativeViewInspectorPrivate *get(QDeclarativeViewInspector *v) { return v->d_func(); }
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEVIEWINSPECTOR_P_P_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
index f8d7ee8360..011644149a 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
+++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
@@ -7,6 +7,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling
QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)"
SOURCES += \
+ abstractviewinspector.cpp \
qdeclarativeinspectorplugin.cpp \
qdeclarativeviewinspector.cpp \
editor/abstractliveedittool.cpp \
@@ -21,27 +22,30 @@ SOURCES += \
editor/zoomtool.cpp \
editor/colorpickertool.cpp \
editor/qmltoolbar.cpp \
- editor/toolbarcolorbox.cpp
+ editor/toolbarcolorbox.cpp \
+ abstracttool.cpp
HEADERS += \
+ abstractviewinspector.h \
qdeclarativeinspectorplugin.h \
qdeclarativeinspectorprotocol.h \
+ qdeclarativeviewinspector.h \
qdeclarativeviewinspector_p.h \
- qdeclarativeviewinspector_p_p.h \
- qmlinspectorconstants_p.h \
- editor/abstractliveedittool_p.h \
- editor/liveselectiontool_p.h \
- editor/livelayeritem_p.h \
- editor/livesingleselectionmanipulator_p.h \
- editor/liverubberbandselectionmanipulator_p.h \
- editor/liveselectionrectangle_p.h \
- editor/liveselectionindicator_p.h \
- editor/boundingrecthighlighter_p.h \
- editor/subcomponentmasklayeritem_p.h \
- editor/zoomtool_p.h \
- editor/colorpickertool_p.h \
- editor/qmltoolbar_p.h \
- editor/toolbarcolorbox_p.h
+ qmlinspectorconstants.h \
+ editor/abstractliveedittool.h \
+ editor/liveselectiontool.h \
+ editor/livelayeritem.h \
+ editor/livesingleselectionmanipulator.h \
+ editor/liverubberbandselectionmanipulator.h \
+ editor/liveselectionrectangle.h \
+ editor/liveselectionindicator.h \
+ editor/boundingrecthighlighter.h \
+ editor/subcomponentmasklayeritem.h \
+ editor/zoomtool.h \
+ editor/colorpickertool.h \
+ editor/qmltoolbar.h \
+ editor/toolbarcolorbox.h \
+ abstracttool.h
RESOURCES += editor/editor.qrc
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h b/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants.h
index 40ec32542d..5335222865 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants.h
@@ -44,12 +44,7 @@
#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
+namespace QmlJSDebugger {
namespace Constants {
enum DesignTool {
@@ -62,11 +57,6 @@ enum DesignTool {
ZoomMode = 6
};
-enum ToolFlags {
- NoToolFlags = 0,
- UseCursorPos = 1
-};
-
static const int DragStartTime = 50;
static const int DragStartDistance = 20;
@@ -82,9 +72,6 @@ enum GraphicsItemTypes {
} // namespace Constants
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
+} // namespace QmlJSDebugger
#endif // QMLINSPECTORCONSTANTS_H
diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
index a40bcc0383..1990c0d67f 100644
--- a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
+++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
@@ -69,6 +69,8 @@ public:
void expandObjectById(const QByteArray& objectName, quint64 objectId);
void setProperty(const QByteArray& id, qint64 objectId, const QString &property, const QString &value);
void activateFrame(int frameId);
+ void startCoverageCompleted();
+ void startCoverageRun();
// info from last exec
JSAgentWatchData exec_data;
@@ -94,6 +96,11 @@ signals:
void stopped();
void expanded();
void watchTriggered();
+ void coverageScriptLoaded();
+ void coverageFuncEntered();
+ void coverageFuncExited();
+ void coveragePosChanged();
+ void coverageCompleted();
protected:
virtual void statusChanged(Status status);
@@ -156,6 +163,9 @@ private slots:
void setProperty4();
void activateFrame2();
void verifyQMLOptimizerDisabled();
+ void testCoverageCompleted();
+ void testCoverageRun();
+
};
@@ -280,6 +290,28 @@ void QJSDebugClient::activateFrame(int frameId)
sendMessage(reply);
}
+void QJSDebugClient::startCoverageRun()
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "COVERAGE";
+ bool enabled = true;
+ rs << cmd
+ << enabled;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::startCoverageCompleted()
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "COVERAGE";
+ bool enabled = false;
+ rs << cmd
+ << enabled;
+ sendMessage(reply);
+}
+
void QJSDebugClient::statusChanged(Status /*status*/)
{
emit statusHasChanged();
@@ -317,6 +349,30 @@ void QJSDebugClient::messageReceived(const QByteArray &data)
stream >> ping;
QCOMPARE(ping, m_ping);
emit pong();
+ } else if (command == "COVERAGE") {
+ qint64 time;
+ int messageType;
+ qint64 scriptId;
+ QString program;
+ QString fileName;
+ int baseLineNumber;
+ int lineNumber;
+ int columnNumber;
+ QString returnValue;
+
+ stream >> time >> messageType >> scriptId >> program >> fileName >> baseLineNumber
+ >> lineNumber >> columnNumber >> returnValue;
+ if (messageType == CoverageComplete) {
+ emit coverageCompleted();
+ } else if (messageType == CoverageScriptLoad) {
+ emit coverageScriptLoaded();
+ } else if (messageType == CoveragePosChange) {
+ emit coveragePosChanged();
+ } else if (messageType == CoverageFuncEntry) {
+ emit coverageFuncEntered();
+ } else if (messageType == CoverageFuncExit) {
+ emit coverageFuncExited();
+ }
} else {
QFAIL("Unknown message :" + command);
}
@@ -1336,6 +1392,51 @@ void tst_QDeclarativeDebugJS::verifyQMLOptimizerDisabled()
QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
}
+
+void tst_QDeclarativeDebugJS::testCoverageCompleted()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QJSDebugClient client(&connection);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ client.startCoverageCompleted();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageCompleted())));
+}
+
+void tst_QDeclarativeDebugJS::testCoverageRun()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QJSDebugClient client(&connection);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ client.startCoverageRun();
+ client.startCoverageCompleted();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageScriptLoaded())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coveragePosChanged())));
+ //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageFuncEntered())));
+ //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageFuncExited())));
+}
+
QTEST_MAIN(tst_QDeclarativeDebugJS)
#include "tst_qdeclarativedebugjs.moc"
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml
index a3e92fe6a6..8359ad1bb4 100644
--- a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml
@@ -1,7 +1,7 @@
import QtQuick 1.0
Flickable {
- width: 100; height: 100
+ width: 100; height: 200
contentWidth: column.width; contentHeight: column.height
Column {
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index b077fdc7ab..4d4c30bf56 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -78,10 +78,12 @@ private slots:
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
void wheel();
+ void flickVelocity();
private:
QDeclarativeEngine engine;
+ void flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration);
template<typename T>
T *findItem(QGraphicsObject *parent, const QString &objectName);
};
@@ -480,6 +482,51 @@ void tst_qdeclarativeflickable::wheel()
delete canvas;
}
+void tst_qdeclarativeflickable::flickVelocity()
+{
+#ifdef Q_WS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems", SkipAll);
+#endif
+
+ QDeclarativeView *canvas = new QDeclarativeView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ // flick up
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // flick down
+ flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
+ QVERIFY(flickable->verticalVelocity() < 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ delete canvas;
+}
+
+void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration)
+{
+ const int pointCount = 5;
+ QPoint diff = to - from;
+
+ // send press, five equally spaced moves, and release.
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(from));
+
+ for (int i = 0; i < pointCount; ++i) {
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(from + (i+1)*diff/pointCount), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::qWait(duration/pointCount);
+ QCoreApplication::processEvents();
+ }
+
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to));
+}
template<typename T>
T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName)
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index e3f798089a..4342ff37bb 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -450,12 +450,12 @@ void tst_QDeclarativeGridView::removed()
model.removeItem(1);
// Confirm items positioned correctly
- for (int i = 6; i < 18; ++i) {
+ for (int i = 3; i < 15; ++i) {
QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), 60+(i/3)*60.0);
}
// Remove currentIndex
@@ -476,7 +476,7 @@ void tst_QDeclarativeGridView::removed()
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
+ QTRY_VERIFY(item->y() == 60+(i/3)*60);
}
// remove item outside current view.
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 403e3b6ff2..ae06d02ec3 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -68,6 +68,9 @@
QString pluginImportPath;
bool verbose = false;
+QString currentProperty;
+QString inObjectInstantiation;
+
void collectReachableMetaObjects(const QMetaObject *meta, QSet<const QMetaObject *> *metas)
{
if (! meta || metas->contains(meta))
@@ -81,8 +84,6 @@ void collectReachableMetaObjects(const QMetaObject *meta, QSet<const QMetaObject
collectReachableMetaObjects(meta->superClass(), metas);
}
-QString currentProperty;
-
void collectReachableMetaObjects(QObject *object, QSet<const QMetaObject *> *metas)
{
if (! object)
@@ -160,29 +161,36 @@ QSet<const QMetaObject *> collectReachableMetaObjects(const QString &importCode,
collectReachableMetaObjects(ty, &metas);
}
- // Adjust ids of extended objects.
- // The chain ends up being:
- // __extended__.originalname - the base object
- // __extension_0_.originalname - first extension
- // ..
- // __extension_n-2_.originalname - second to last extension
- // originalname - last extension
- // ### does this actually work for multiple extensions? it seems like the prototypes might be wrong
- foreach (const QByteArray &extendedCpp, extensions.keys()) {
- cppToId.remove(extendedCpp);
- const QByteArray extendedId = convertToId(extendedCpp);
- cppToId.insert(extendedCpp, "__extended__." + extendedId);
- QSet<QByteArray> extensionCppNames = extensions.value(extendedCpp);
- int c = 0;
+ // Adjust exports of the base object if there are extensions.
+ // For each export of a base object there can be a single extension object overriding it.
+ // Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export
+ // of QGraphicsWidget.
+ foreach (const QByteArray &baseCpp, extensions.keys()) {
+ QSet<const QDeclarativeType *> baseExports = qmlTypesByCppName.value(baseCpp);
+
+ const QSet<QByteArray> extensionCppNames = extensions.value(baseCpp);
foreach (const QByteArray &extensionCppName, extensionCppNames) {
- if (c != extensionCppNames.size() - 1) {
- QByteArray adjustedName = QString("__extension__%1.%2").arg(QString::number(c), QString(extendedId)).toAscii();
- cppToId.insert(extensionCppName, adjustedName);
- } else {
- cppToId.insert(extensionCppName, extendedId);
+ const QSet<const QDeclarativeType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
+
+ // remove extension exports from base imports
+ // unfortunately the QDeclarativeType pointers don't match, so can't use QSet::substract
+ QSet<const QDeclarativeType *> newBaseExports;
+ foreach (const QDeclarativeType *baseExport, baseExports) {
+ bool match = false;
+ foreach (const QDeclarativeType *extensionExport, extensionExports) {
+ if (baseExport->qmlTypeName() == extensionExport->qmlTypeName()
+ && baseExport->majorVersion() == extensionExport->majorVersion()
+ && baseExport->minorVersion() == extensionExport->minorVersion()) {
+ match = true;
+ break;
+ }
+ }
+ if (!match)
+ newBaseExports.insert(baseExport);
}
- ++c;
+ baseExports = newBaseExports;
}
+ qmlTypesByCppName[baseCpp] = baseExports;
}
// find even more QMetaObjects by instantiating QML types and running
@@ -207,7 +215,10 @@ QSet<const QMetaObject *> collectReachableMetaObjects(const QString &importCode,
QDeclarativeComponent c(engine);
c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/typeinstance.qml"));
+ inObjectInstantiation = tyName;
QObject *object = c.create();
+ inObjectInstantiation.clear();
+
if (object)
collectReachableMetaObjects(object, &metas);
else
@@ -261,6 +272,9 @@ public:
if (qmlTyName.startsWith(relocatableModuleUri + QLatin1Char('/'))) {
qmlTyName.remove(0, relocatableModuleUri.size() + 1);
}
+ if (qmlTyName.startsWith("./")) {
+ qmlTyName.remove(0, 2);
+ }
exports += enquote(QString("%1 %2.%3").arg(
qmlTyName,
QString::number(qmlTy->majorVersion()),
@@ -426,6 +440,8 @@ void sigSegvHandler(int) {
fprintf(stderr, "Error: SEGV\n");
if (!currentProperty.isEmpty())
fprintf(stderr, "While processing the property '%s', which probably has uninitialized data.\n", currentProperty.toLatin1().constData());
+ if (!inObjectInstantiation.isEmpty())
+ fprintf(stderr, "While instantiating the object '%s'.\n", inObjectInstantiation.toLatin1().constData());
exit(EXIT_SEGV);
}
#endif
@@ -523,11 +539,16 @@ int main(int argc, char *argv[])
QDeclarativeView view;
QDeclarativeEngine *engine = view.engine();
- if (!pluginImportPath.isEmpty())
+ if (!pluginImportPath.isEmpty()) {
+ QDir cur = QDir::current();
+ cur.cd(pluginImportPath);
+ pluginImportPath = cur.absolutePath();
+ QDir::setCurrent(pluginImportPath);
engine->addImportPath(pluginImportPath);
+ }
// find all QMetaObjects reachable from the builtin module
- QByteArray importCode("import QtQuick 1.1\n");
+ QByteArray importCode("import QtQuick 1.0\n");
QSet<const QMetaObject *> defaultReachable = collectReachableMetaObjects(importCode, engine);
// this will hold the meta objects we want to dump information of
diff --git a/tools/qmlplugindump/qmlplugindump.pro b/tools/qmlplugindump/qmlplugindump.pro
index 53827e2f40..e9fcdc7f24 100644
--- a/tools/qmlplugindump/qmlplugindump.pro
+++ b/tools/qmlplugindump/qmlplugindump.pro
@@ -16,5 +16,22 @@ HEADERS += \
OTHER_FILES += Info.plist
macx: QMAKE_INFO_PLIST = Info.plist
+# Build debug and release versions of the tool on Windows -
+# if debug and release versions of Qt have been built.
+!build_pass:win32 {
+ CONFIG -= debug release debug_and_release build_all
+
+ contains(QT_CONFIG,debug):contains(QT_CONFIG,release) {
+ CONFIG += debug_and_release build_all
+ } else {
+ contains(QT_CONFIG,debug): CONFIG += debug
+ contains(QT_CONFIG,release): CONFIG += release
+ }
+}
+
+CONFIG(debug, debug|release) {
+ win32: TARGET = $$join(TARGET,,,d)
+}
+
target.path = $$[QT_INSTALL_BINS]
INSTALLS += target