Commit f7fee744 authored by hjk's avatar hjk Committed by hjk

qmlprofiler: ui and style

Change-Id: I2153ef00f8d3c6d1cc4d39648916cad865b5a9be
Reviewed-on: http://codereview.qt.nokia.com/54
Reviewed-by: hjk
parent cc645911
......@@ -35,7 +35,7 @@
namespace QmlJsDebugClient {
#define MAX_PACKET_SIZE 0x7FFFFFFF
static const unsigned int MAX_PACKET_SIZE = 0x7FFFFFFF;
/*!
\class QPacketProtocol
......@@ -100,9 +100,10 @@ namespace QmlJsDebugClient {
class QPacketProtocolPrivate : public QObject
{
Q_OBJECT
Q_OBJECT
public:
QPacketProtocolPrivate(QPacketProtocol * parent, QIODevice * _dev)
QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev)
: QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
dev(_dev)
{
......@@ -139,8 +140,8 @@ public Q_SLOTS:
{
Q_ASSERT(!sendingPackets.isEmpty());
while(bytes) {
if(sendingPackets.at(0) > bytes) {
while (bytes) {
if (sendingPackets.at(0) > bytes) {
sendingPackets[0] -= bytes;
bytes = 0;
} else {
......@@ -153,11 +154,11 @@ public Q_SLOTS:
void readyToRead()
{
while(true) {
while (true) {
// Need to get trailing data
if(-1 == inProgressSize) {
if (-1 == inProgressSize) {
// We need a size header of sizeof(qint32)
if(sizeof(qint32) > (uint)dev->bytesAvailable())
if (sizeof(qint32) > (uint)dev->bytesAvailable())
return;
// Read size header
......@@ -166,7 +167,7 @@ public Q_SLOTS:
Q_UNUSED(read);
// Check sizing constraints
if(inProgressSize > maxPacketSize) {
if (inProgressSize > maxPacketSize) {
QObject::disconnect(dev, SIGNAL(readyRead()),
this, SLOT(readyToRead()));
QObject::disconnect(dev, SIGNAL(aboutToClose()),
......@@ -182,7 +183,7 @@ public Q_SLOTS:
} else {
inProgress.append(dev->read(inProgressSize - inProgress.size()));
if(inProgressSize == inProgress.size()) {
if (inProgressSize == inProgress.size()) {
// Packet has arrived!
packets.append(inProgress);
inProgressSize = -1;
......@@ -242,7 +243,7 @@ qint32 QPacketProtocol::maximumPacketSize() const
*/
qint32 QPacketProtocol::setMaximumPacketSize(qint32 max)
{
if(max > (signed)sizeof(qint32))
if (max > (signed)sizeof(qint32))
d->maxPacketSize = max;
return d->maxPacketSize;
}
......@@ -269,7 +270,7 @@ QPacketAutoSend QPacketProtocol::send()
*/
void QPacketProtocol::send(const QPacket & p)
{
if(p.b.isEmpty())
if (p.b.isEmpty())
return; // We don't send empty packets
qint64 sendSize = p.b.size() + sizeof(qint32);
......@@ -304,7 +305,7 @@ void QPacketProtocol::clear()
*/
QPacket QPacketProtocol::read()
{
if(0 == d->packets.count())
if (0 == d->packets.count())
return QPacket();
QPacket rv(d->packets.at(0));
......@@ -402,7 +403,7 @@ QPacket::QPacket()
*/
QPacket::~QPacket()
{
if(buf) {
if (buf) {
delete buf;
buf = 0;
}
......@@ -477,10 +478,10 @@ QPacketAutoSend::QPacketAutoSend(QPacketProtocol * _p)
QPacketAutoSend::~QPacketAutoSend()
{
if(!b.isEmpty())
if (!b.isEmpty())
p->send(*this);
}
}
} // namespace QmlJsDebugClient
#include <qpacketprotocol.moc>
......@@ -35,8 +35,6 @@
#include <QtCore/qobject.h>
#include <QtCore/qdatastream.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QIODevice;
class QBuffer;
......@@ -51,9 +49,10 @@ class QPacketProtocolPrivate;
class QPacketProtocol : public QObject
{
Q_OBJECT
Q_OBJECT
public:
explicit QPacketProtocol(QIODevice * dev, QObject * parent = 0);
explicit QPacketProtocol(QIODevice *dev, QObject *parent = 0);
virtual ~QPacketProtocol();
qint32 maximumPacketSize() const;
......@@ -67,7 +66,7 @@ public:
void clear();
QIODevice * device();
QIODevice *device();
Q_SIGNALS:
void readyRead();
......@@ -75,7 +74,7 @@ Q_SIGNALS:
void packetWritten();
private:
QPacketProtocolPrivate * d;
QPacketProtocolPrivate *d;
};
......@@ -91,9 +90,9 @@ public:
protected:
friend class QPacketProtocol;
QPacket(const QByteArray & ba);
QPacket(const QByteArray &ba);
QByteArray b;
QBuffer * buf;
QBuffer *buf;
};
class QPacketAutoSend : public QPacket
......@@ -104,11 +103,9 @@ public:
private:
friend class QPacketProtocol;
QPacketAutoSend(QPacketProtocol *);
QPacketProtocol * p;
QPacketProtocol *p;
};
}
QT_END_HEADER
} // QmlJsDebugClient
#endif
......@@ -55,34 +55,15 @@
#include "canvas/qdeclarativetiledcanvas_p.h"
using namespace QmlProfiler::Internal;
namespace QmlProfiler {
namespace Internal {
//
// QmlProfilerEnginePrivate
//
class QmlProfilerEngine::QmlProfilerEnginePrivate
{
public:
QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {}
~QmlProfilerEnginePrivate() {}
bool attach(const QString &address, uint port);
static AbstractQmlProfilerRunner *createRunner(const Analyzer::AnalyzerStartParameters &m_params, QObject *parent);
QmlProfilerEngine *q;
Analyzer::AnalyzerStartParameters m_params;
AbstractQmlProfilerRunner *m_runner;
bool m_running;
bool m_fetchingData;
bool m_delayedDelete;
};
AbstractQmlProfilerRunner *
QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(const Analyzer::AnalyzerStartParameters &m_params, QObject *parent)
static AbstractQmlProfilerRunner *
createRunner(const Analyzer::AnalyzerStartParameters &m_params, QObject *parent)
{
AbstractQmlProfilerRunner *runner = 0;
if (m_params.startMode == Analyzer::StartLocal) {
......@@ -101,16 +82,35 @@ QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(const Analyzer::Analyz
return runner;
}
class QmlProfilerEngine::QmlProfilerEnginePrivate
{
public:
QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {}
~QmlProfilerEnginePrivate() {}
bool attach(const QString &address, uint port);
QmlProfilerEngine *q;
Analyzer::AnalyzerStartParameters m_params;
AbstractQmlProfilerRunner *m_runner;
bool m_running;
bool m_fetchingData;
bool m_delayedDelete;
};
//
// QmlProfilerEngine
//
QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration)
QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: IAnalyzerEngine(sp, runConfiguration)
, d(new QmlProfilerEnginePrivate(this))
{
d->m_params = sp;
d->m_running = false;
d->m_fetchingData = false;
d->m_delayedDelete = false;
......@@ -126,7 +126,7 @@ QmlProfilerEngine::~QmlProfilerEngine()
void QmlProfilerEngine::start()
{
QTC_ASSERT(!d->m_runner, return);
d->m_runner = QmlProfilerEnginePrivate::createRunner(d->m_params, this);
d->m_runner = createRunner(d->m_params, this);
QTC_ASSERT(d->m_runner, return);
connect(d->m_runner, SIGNAL(started()), this, SIGNAL(processRunning()));
......@@ -163,7 +163,8 @@ void QmlProfilerEngine::setFetchingData(bool b)
d->m_fetchingData = b;
}
void QmlProfilerEngine::dataReceived() {
void QmlProfilerEngine::dataReceived()
{
if (d->m_delayedDelete)
finishProcess();
d->m_delayedDelete = false;
......@@ -175,7 +176,6 @@ void QmlProfilerEngine::finishProcess()
if (d->m_running) {
d->m_running = false;
d->m_runner->stop();
emit finished();
}
}
......@@ -184,3 +184,6 @@ void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputF
{
qDebug() << "app: " << msg;
}
} // namespace Internal
} // namespace QmlProfiler
......@@ -58,7 +58,6 @@ class QmlProfilerSummaryView::QmlProfilerSummaryViewPrivate
{
public:
QmlProfilerSummaryViewPrivate(QmlProfilerSummaryView *qq) : q(qq) {}
~QmlProfilerSummaryViewPrivate() {}
QmlProfilerSummaryView *q;
......@@ -79,9 +78,9 @@ public:
class ProfilerItem : public QStandardItem
{
public:
ProfilerItem(const QString &text):QStandardItem ( text ) {}
ProfilerItem(const QString &text) : QStandardItem(text) {}
virtual bool operator< ( const QStandardItem & other ) const
virtual bool operator<(const QStandardItem &other) const
{
if (data().type() == QVariant::String) {
// first column
......@@ -124,7 +123,7 @@ void QmlProfilerSummaryView::clean()
d->m_model->setColumnCount(7);
// clean the hash
QHashIterator<QString, BindingData *>it(d->m_bindingHash);
QHashIterator<QString, BindingData *> it(d->m_bindingHash);
while (it.hasNext()) {
it.next();
delete it.value();
......@@ -135,7 +134,8 @@ void QmlProfilerSummaryView::clean()
setSortingEnabled(false);
}
void QmlProfilerSummaryView::addRangedEvent(int type, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line)
void QmlProfilerSummaryView::addRangedEvent(int type, qint64 startTime, qint64 length,
const QStringList &data, const QString &fileName, int line)
{
Q_UNUSED(startTime);
Q_UNUSED(data);
......@@ -191,7 +191,7 @@ void QmlProfilerSummaryView::complete()
it.next();
BindingData *binding = it.value();
binding->percent = binding->duration * 100.0 / totalTime;
binding->tpc = binding->calls>0? (double)binding->duration / binding->calls : 0;
binding->tpc = binding->calls > 0 ? double(binding->duration) / binding->calls : 0;
appendRow(binding->displayname,
binding->filename,
......@@ -228,7 +228,7 @@ void QmlProfilerSummaryView::appendRow(const QString &displayName,
double maxTime,
double minTime)
{
QString location =fileName+QLatin1Char(':')+QString::number(line);
QString location = fileName + QLatin1Char(':') + QString::number(line);
ProfilerItem *locationColumn = new ProfilerItem(displayName);
locationColumn->setData(QVariant(location),Qt::UserRole+1);
locationColumn->setData(QVariant(fileName),Qt::UserRole+2);
......@@ -260,9 +260,9 @@ void QmlProfilerSummaryView::appendRow(const QString &displayName,
QString QmlProfilerSummaryView::displayTime(double time) const
{
if (time<1e6)
if (time < 1e6)
return QString::number(time/1e3,'f',3) + QString::fromWCharArray(L" \u03BCs");
if (time<1e9)
if (time < 1e9)
return QString::number(time/1e6,'f',3) + QLatin1String(" ms");
return QString::number(time/1e9,'f',3) + QLatin1String(" s");
......@@ -270,11 +270,11 @@ QString QmlProfilerSummaryView::displayTime(double time) const
void QmlProfilerSummaryView::setHeaderLabels()
{
d->m_model->setHeaderData(0,Qt::Horizontal,QVariant(tr("location")));
d->m_model->setHeaderData(1,Qt::Horizontal,QVariant(tr("% time")));
d->m_model->setHeaderData(2,Qt::Horizontal,QVariant(tr("total time")));
d->m_model->setHeaderData(3,Qt::Horizontal,QVariant(tr("calls")));
d->m_model->setHeaderData(4,Qt::Horizontal,QVariant(tr("time per call")));
d->m_model->setHeaderData(5,Qt::Horizontal,QVariant(tr("longest time")));
d->m_model->setHeaderData(6,Qt::Horizontal,QVariant(tr("shortest time")));
d->m_model->setHeaderData(0, Qt::Horizontal, QVariant(tr("Location")));
d->m_model->setHeaderData(1, Qt::Horizontal, QVariant(tr("Time in Percent")));
d->m_model->setHeaderData(2, Qt::Horizontal, QVariant(tr("Total Time")));
d->m_model->setHeaderData(3, Qt::Horizontal, QVariant(tr("Calls")));
d->m_model->setHeaderData(4, Qt::Horizontal, QVariant(tr("Time per Call")));
d->m_model->setHeaderData(5, Qt::Horizontal, QVariant(tr("Longest Time")));
d->m_model->setHeaderData(6, Qt::Horizontal, QVariant(tr("Shortest Time")));
}
......@@ -103,17 +103,17 @@ public:
QmlProfilerTool::QmlProfilerTool(QObject *parent)
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
{
d->m_client = 0;
d->m_connectionAttempts = 0;
d->m_traceWindow = 0;
d->m_project = 0;
d->m_runConfiguration = 0;
d->m_isAttached = false;
d->m_attachAction = 0;
d->m_recordingEnabled = true;
d->m_connectionTimer.setInterval(200);
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
d->m_client = 0;
d->m_connectionAttempts = 0;
d->m_traceWindow = 0;
d->m_project = 0;
d->m_runConfiguration = 0;
d->m_isAttached = false;
d->m_attachAction = 0;
d->m_recordingEnabled = true;
d->m_connectionTimer.setInterval(200);
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
}
QmlProfilerTool::~QmlProfilerTool()
......@@ -247,12 +247,12 @@ QWidget *QmlProfilerTool::createControlWidget()
d->m_recordButton->setChecked(true);
layout->addWidget(d->m_recordButton);
QLabel *timeLabel = new QLabel(tr("elapsed: 0 s"));
QLabel *timeLabel = new QLabel(QLatin1Char(' ') + tr("Elapsed: 0 s"));
QPalette palette = timeLabel->palette();
palette.setColor(QPalette::WindowText, Qt::white);
timeLabel->setPalette(palette);
connect(this,SIGNAL(setTimeLabel(QString)),timeLabel,SLOT(setText(QString)));
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
layout->addWidget(timeLabel);
toolbarWidget->setLayout(layout);
......
......@@ -65,12 +65,6 @@ AnalyzerStartParameters localStartParameters(ProjectExplorer::RunConfiguration *
QmlProjectAnalyzerRunControlFactory::QmlProjectAnalyzerRunControlFactory(QObject *parent)
: IRunControlFactory(parent)
{
}
QmlProjectAnalyzerRunControlFactory::~QmlProjectAnalyzerRunControlFactory()
{
}
bool QmlProjectAnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
......@@ -82,8 +76,8 @@ bool QmlProjectAnalyzerRunControlFactory::canRun(RunConfiguration *runConfigurat
RunControl *QmlProjectAnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode)
{
if (!qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration) ||
mode != Constants::MODE_ANALYZE) {
if (!qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration)
|| mode != Constants::MODE_ANALYZE) {
return 0;
}
const AnalyzerStartParameters sp = localStartParameters(runConfiguration);
......@@ -109,7 +103,7 @@ IRunConfigurationAspect *QmlProjectAnalyzerRunControlFactory::createRunConfigura
RunConfigWidget *QmlProjectAnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
{
QmlProjectManager::QmlProjectRunConfiguration *localRc =
QmlProjectManager::QmlProjectRunConfiguration *localRc =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
if (!localRc)
return 0;
......@@ -121,5 +115,4 @@ RunConfigWidget *QmlProjectAnalyzerRunControlFactory::createConfigurationWidget(
Analyzer::AnalyzerRunConfigWidget *ret = new Analyzer::AnalyzerRunConfigWidget;
ret->setRunConfiguration(runConfiguration);
return ret;
// return 0;
}
......@@ -44,13 +44,13 @@ namespace Internal {
class QmlProjectAnalyzerRunControlFactory : public ProjectExplorer::IRunControlFactory
{
Q_OBJECT
public:
typedef ProjectExplorer::RunConfiguration RunConfiguration;
QmlProjectAnalyzerRunControlFactory(QObject *parent = 0);
~QmlProjectAnalyzerRunControlFactory();
// virtuals from IRunControlFactory
// IRunControlFactory implementation
bool canRun(RunConfiguration *runConfiguration, const QString &mode) const;
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, const QString &mode);
Analyzer::AnalyzerRunControl *create(const Analyzer::AnalyzerStartParameters &sp, RunConfiguration *runConfiguration = 0);
......
......@@ -33,6 +33,8 @@
#include "tracewindow.h"
#include "qmlprofilerplugin.h"
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qdatastream.h>
......@@ -50,11 +52,7 @@
#include <QtDeclarative/qdeclarativecontext.h>
#include <QtDeclarative/qdeclarative.h>
#include "qmlprofilerplugin.h"
//#include <jsdebuggeragent.h>
//#include <qdeclarativeviewobserver.h>
#define GAP_TIME 150
static const int GAP_TIME = 150;
using QmlJsDebugClient::QDeclarativeDebugClient;
......@@ -72,7 +70,7 @@ struct Location
class TracePlugin : public QDeclarativeDebugClient
{
Q_OBJECT
Q_PROPERTY(bool recording READ recording WRITE setRecording NOTIFY recordingChanged)
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
public:
TracePlugin(QDeclarativeDebugConnection *client);
......@@ -106,10 +104,7 @@ public:
MaximumRangeType
};
bool recording() const
{
return m_recording;
}
bool isRecording() const { return m_recording; }
public slots:
void setRecording(bool);
......@@ -133,7 +128,6 @@ protected:
virtual void messageReceived(const QByteArray &);
private:
qint64 m_inProgressRanges;
QStack<qint64> m_rangeStartTimes[MaximumRangeType];
QStack<QStringList> m_rangeDatas[MaximumRangeType];
......@@ -143,13 +137,9 @@ private:
bool m_recording;
};
} // namespace Internal
} // namespace QmlProfiler
using namespace QmlProfiler::Internal;
TracePlugin::TracePlugin(QDeclarativeDebugConnection *client)
: QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), client), m_inProgressRanges(0), m_maximumTime(0), m_recording(false)
: QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), client),
m_inProgressRanges(0), m_maximumTime(0), m_recording(false)
{
::memset(m_rangeCount, 0, MaximumRangeType * sizeof(int));
}
......@@ -268,7 +258,7 @@ void TracePlugin::messageReceived(const QByteArray &data)
}
TraceWindow::TraceWindow(QWidget *parent)
: QWidget(parent)
: QWidget(parent)
{
setObjectName(tr("QML Performance Monitor"));
......@@ -340,7 +330,11 @@ void TraceWindow::setRecording(bool recording)
bool TraceWindow::isRecording() const
{
return (m_plugin.data()->recording());
return m_plugin.data()->isRecording();
}
} // namespace Internal
} // namespace QmlProfiler
#include "tracewindow.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment