QmlProfiler: Move EventList to qmljsdebugclient library

Change-Id: Icbd24ffeb51db0f098d8fe9c62a0a889a722f760
Reviewed-on: http://codereview.qt.nokia.com/3222
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
This commit is contained in:
Kai Koehne
2011-08-18 16:10:33 +02:00
parent 91e22b2e81
commit 749534ea76
10 changed files with 53 additions and 56 deletions

View File

@@ -12,13 +12,15 @@ HEADERS += \
$$PWD/qdeclarativedebugclient.h \ $$PWD/qdeclarativedebugclient.h \
$$PWD/qmljsdebugclient_global.h \ $$PWD/qmljsdebugclient_global.h \
$$PWD/qmlprofilertraceclient.h \ $$PWD/qmlprofilertraceclient.h \
$$PWD/qmlprofilereventtypes.h $$PWD/qmlprofilereventtypes.h \
$$PWD/qmlprofilereventlist.h
SOURCES += \ SOURCES += \
$$PWD/qdeclarativeenginedebug.cpp \ $$PWD/qdeclarativeenginedebug.cpp \
$$PWD/qpacketprotocol.cpp \ $$PWD/qpacketprotocol.cpp \
$$PWD/qdeclarativedebugclient.cpp \ $$PWD/qdeclarativedebugclient.cpp \
$$PWD/qmlprofilertraceclient.cpp $$PWD/qmlprofilertraceclient.cpp \
$$PWD/qmlprofilereventlist.cpp
OTHER_FILES += \ OTHER_FILES += \
$$PWD/qmljsdebugclient.pri \ $$PWD/qmljsdebugclient.pri \

View File

@@ -32,7 +32,6 @@
#include "qmlprofilereventlist.h" #include "qmlprofilereventlist.h"
#include <coreplugin/icore.h>
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtCore/QHash> #include <QtCore/QHash>
#include <QtCore/QtAlgorithms> #include <QtCore/QtAlgorithms>
@@ -44,13 +43,10 @@
#include <QtCore/QXmlStreamWriter> #include <QtCore/QXmlStreamWriter>
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtGui/QMainWindow>
#include <QtGui/QMessageBox>
#include <QDebug> #include <QDebug>
namespace QmlProfiler { namespace QmlJsDebugClient {
namespace Internal {
#define MIN_LEVEL 1 #define MIN_LEVEL 1
@@ -590,16 +586,16 @@ int QmlProfilerEventList::count() const
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
void QmlProfilerEventList::save(const QString &filename) const void QmlProfilerEventList::save(const QString &filename)
{ {
if (count() == 0) { if (count() == 0) {
showErrorDialog(tr("No data to save")); emit error(tr("No data to save"));
return; return;
} }
QFile file(filename); QFile file(filename);
if (!file.open(QIODevice::WriteOnly)) { if (!file.open(QIODevice::WriteOnly)) {
showErrorDialog(tr("Could not open %1 for writing").arg(filename)); emit error(tr("Could not open %1 for writing").arg(filename));
return; return;
} }
@@ -659,7 +655,7 @@ void QmlProfilerEventList::load()
QFile file(filename); QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
showErrorDialog(tr("Could not open %1 for reading").arg(filename)); emit error(tr("Could not open %1 for reading").arg(filename));
return; return;
} }
@@ -761,7 +757,7 @@ void QmlProfilerEventList::load()
file.close(); file.close();
if (stream.hasError()) { if (stream.hasError()) {
showErrorDialog(tr("Error while parsing %1").arg(filename)); emit error(tr("Error while parsing %1").arg(filename));
clear(); clear();
return; return;
} }
@@ -794,19 +790,6 @@ void QmlProfilerEventList::load()
postProcess(); postProcess();
} }
void QmlProfilerEventList::showErrorDialog(const QString &st ) const
{
Core::ICore * const core = Core::ICore::instance();
QMessageBox *errorDialog = new QMessageBox(core->mainWindow());
errorDialog->setIcon(QMessageBox::Warning);
errorDialog->setWindowTitle(tr("QML Profiler"));
errorDialog->setText( st );
errorDialog->setStandardButtons(QMessageBox::Ok);
errorDialog->setDefaultButton(QMessageBox::Ok);
errorDialog->setModal(false);
errorDialog->show();
}
/////////////////////////////////////////////// ///////////////////////////////////////////////
qint64 QmlProfilerEventList::getStartTime(int index) const { qint64 QmlProfilerEventList::getStartTime(int index) const {
return d->m_startTimeSortedList[index].startTime; return d->m_startTimeSortedList[index].startTime;
@@ -845,5 +828,4 @@ QString QmlProfilerEventList::getDetails(int index) const {
} }
} // namespace Internal } // namespace QmlJsDebugClient
} // namespace QmlProfiler

View File

@@ -33,14 +33,15 @@
#ifndef QMLPROFILEREVENTLIST_H #ifndef QMLPROFILEREVENTLIST_H
#define QMLPROFILEREVENTLIST_H #define QMLPROFILEREVENTLIST_H
#include <QObject> #include "qmlprofilereventtypes.h"
#include "qmljsdebugclient_global.h"
#include <QtCore/QHash> #include <QtCore/QHash>
#include "qmljsdebugclient/qmlprofilereventtypes.h" #include <QtCore/QObject>
namespace QmlProfiler { namespace QmlJsDebugClient {
namespace Internal {
struct QmlEventData struct QMLJSDEBUGCLIENT_EXPORT QmlEventData
{ {
QString displayname; QString displayname;
QString filename; QString filename;
@@ -70,7 +71,7 @@ enum ParsingStatus {
DoneStatus = 5 DoneStatus = 5
}; };
class QmlProfilerEventList : public QObject class QMLJSDEBUGCLIENT_EXPORT QmlProfilerEventList : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -105,13 +106,14 @@ signals:
void dataReady(); void dataReady();
void countChanged(); void countChanged();
void parsingStatusChanged(); void parsingStatusChanged();
void error(const QString &error);
public slots: public slots:
void clear(); void clear();
void addRangedEvent(int type, qint64 startTime, qint64 length, void addRangedEvent(int type, qint64 startTime, qint64 length,
const QStringList &data, const QString &fileName, int line); const QStringList &data, const QString &fileName, int line);
void complete(); void complete();
void save(const QString &filename) const; void save(const QString &filename);
void load(const QString &filename); void load(const QString &filename);
void setFilename(const QString &filename); void setFilename(const QString &filename);
void load(); void load();
@@ -132,7 +134,6 @@ private:
}; };
} // namespace Internal } // namespace QmlJsDebugClient
} // namespace QmlProfiler
#endif // QMLPROFILEREVENTLIST_H #endif // QMLPROFILEREVENTLIST_H

View File

@@ -27,8 +27,7 @@ SOURCES += \
codaqmlprofilerrunner.cpp \ codaqmlprofilerrunner.cpp \
remotelinuxqmlprofilerrunner.cpp \ remotelinuxqmlprofilerrunner.cpp \
qmlprofilereventview.cpp \ qmlprofilereventview.cpp \
qmlprofilerruncontrolfactory.cpp \ qmlprofilerruncontrolfactory.cpp
qmlprofilereventlist.cpp
HEADERS += \ HEADERS += \
qmlprofilerconstants.h \ qmlprofilerconstants.h \
@@ -44,8 +43,7 @@ HEADERS += \
codaqmlprofilerrunner.h \ codaqmlprofilerrunner.h \
remotelinuxqmlprofilerrunner.h \ remotelinuxqmlprofilerrunner.h \
qmlprofilereventview.h \ qmlprofilereventview.h \
qmlprofilerruncontrolfactory.h\ qmlprofilerruncontrolfactory.h
qmlprofilereventlist.h
RESOURCES += \ RESOURCES += \
qml/qml.qrc qml/qml.qrc

View File

@@ -35,13 +35,13 @@
#include <QTreeView> #include <QTreeView>
#include <qmljsdebugclient/qmlprofilereventtypes.h> #include <qmljsdebugclient/qmlprofilereventtypes.h>
#include "qmlprofilereventlist.h" #include <qmljsdebugclient/qmlprofilereventlist.h>
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
typedef QHash<QString, QmlEventData *> QmlEventHash; typedef QHash<QString, QmlJsDebugClient::QmlEventData *> QmlEventHash;
typedef QList<QmlEventData *> QmlEventList; typedef QList<QmlJsDebugClient::QmlEventData *> QmlEventList;
enum ItemRole { enum ItemRole {
LocationRole = Qt::UserRole+1, LocationRole = Qt::UserRole+1,
@@ -77,10 +77,10 @@ public:
MaxViewTypes MaxViewTypes
}; };
explicit QmlProfilerEventsView(QWidget *parent, QmlProfilerEventList *model); explicit QmlProfilerEventsView(QWidget *parent, QmlJsDebugClient::QmlProfilerEventList *model);
~QmlProfilerEventsView(); ~QmlProfilerEventsView();
void setEventStatisticsModel( QmlProfilerEventList *model ); void setEventStatisticsModel(QmlJsDebugClient::QmlProfilerEventList *model);
void setFieldViewable(Fields field, bool show); void setFieldViewable(Fields field, bool show);
void setViewType(ViewTypes type); void setViewType(ViewTypes type);
void setShowAnonymousEvents( bool showThem ); void setShowAnonymousEvents( bool showThem );

View File

@@ -35,12 +35,12 @@
#include "qmlprofilerplugin.h" #include "qmlprofilerplugin.h"
#include "qmlprofilerconstants.h" #include "qmlprofilerconstants.h"
#include "qmlprofilerattachdialog.h" #include "qmlprofilerattachdialog.h"
#include "qmlprofilereventlist.h"
#include "qmlprofilereventview.h" #include "qmlprofilereventview.h"
#include "tracewindow.h" #include "tracewindow.h"
#include "timelineview.h" #include "timelineview.h"
#include <qmljsdebugclient/qmlprofilereventlist.h>
#include <qmljsdebugclient/qdeclarativedebugclient.h> #include <qmljsdebugclient/qdeclarativedebugclient.h>
#include <analyzerbase/analyzermanager.h> #include <analyzerbase/analyzermanager.h>
@@ -255,6 +255,7 @@ QWidget *QmlProfilerTool::createWidgets()
connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)),this, SLOT(gotoSourceLocation(QString,int))); connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)),this, SLOT(gotoSourceLocation(QString,int)));
connect(d->m_traceWindow, SIGNAL(timeChanged(qreal)), this, SLOT(updateTimer(qreal))); connect(d->m_traceWindow, SIGNAL(timeChanged(qreal)), this, SLOT(updateTimer(qreal)));
connect(d->m_traceWindow, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(d->m_traceWindow, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
connect(d->m_traceWindow->getEventList(), SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString)));
d->m_eventsView = new QmlProfilerEventsView(mw, d->m_traceWindow->getEventList()); d->m_eventsView = new QmlProfilerEventsView(mw, d->m_traceWindow->getEventList());
d->m_eventsView->setViewType(QmlProfilerEventsView::EventsView); d->m_eventsView->setViewType(QmlProfilerEventsView::EventsView);
@@ -582,3 +583,16 @@ void QmlProfilerTool::showLoadDialog()
QTimer::singleShot(100, d->m_traceWindow->getEventList(), SLOT(load())); QTimer::singleShot(100, d->m_traceWindow->getEventList(), SLOT(load()));
} }
} }
void QmlProfilerTool::showErrorDialog(const QString &error)
{
Core::ICore *core = Core::ICore::instance();
QMessageBox *errorDialog = new QMessageBox(core->mainWindow());
errorDialog->setIcon(QMessageBox::Warning);
errorDialog->setWindowTitle(tr("QML Profiler"));
errorDialog->setText(error);
errorDialog->setStandardButtons(QMessageBox::Ok);
errorDialog->setDefaultButton(QMessageBox::Ok);
errorDialog->setModal(false);
errorDialog->show();
}

View File

@@ -90,6 +90,7 @@ private slots:
void connectionStateChanged(); void connectionStateChanged();
void showSaveDialog(); void showSaveDialog();
void showLoadDialog(); void showLoadDialog();
void showErrorDialog(const QString &error);
private: private:
void connectToClient(); void connectToClient();

View File

@@ -35,7 +35,7 @@
#include <QtDeclarative/QDeclarativeItem> #include <QtDeclarative/QDeclarativeItem>
#include <QtScript/QScriptValue> #include <QtScript/QScriptValue>
#include <qmlprofilereventlist.h> #include <qmljsdebugclient/qmlprofilereventlist.h>
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
@@ -81,10 +81,10 @@ public:
qreal cachedProgress() const; qreal cachedProgress() const;
QmlProfilerEventList *eventList() const { return m_eventList; } QmlJsDebugClient::QmlProfilerEventList *eventList() const { return m_eventList; }
void setEventList(QObject *eventList) void setEventList(QObject *eventList)
{ {
m_eventList = qobject_cast<QmlProfilerEventList *>(eventList); m_eventList = qobject_cast<QmlJsDebugClient::QmlProfilerEventList *>(eventList);
emit eventListChanged(m_eventList); emit eventListChanged(m_eventList);
} }
@@ -100,7 +100,7 @@ signals:
void endTimeChanged(qint64 arg); void endTimeChanged(qint64 arg);
void startXChanged(qreal arg); void startXChanged(qreal arg);
void totalWidthChanged(qreal arg); void totalWidthChanged(qreal arg);
void eventListChanged(QmlProfilerEventList *list); void eventListChanged(QmlJsDebugClient::QmlProfilerEventList *list);
void cachedProgressChanged(); void cachedProgressChanged();
void cacheReady(); void cacheReady();
@@ -157,7 +157,7 @@ private:
int prevMin; int prevMin;
int prevMax; int prevMax;
QmlProfilerEventList *m_eventList; QmlJsDebugClient::QmlProfilerEventList *m_eventList;
qreal m_totalWidth; qreal m_totalWidth;
int m_lastCachedIndex; int m_lastCachedIndex;

View File

@@ -33,9 +33,8 @@
#include "tracewindow.h" #include "tracewindow.h"
#include "qmlprofilerplugin.h" #include "qmlprofilerplugin.h"
#include "qmlprofilereventlist.h"
#include <qmljsdebugclient/qdeclarativedebugclient.h> #include <qmljsdebugclient/qmlprofilereventlist.h>
#include <qmljsdebugclient/qmlprofilertraceclient.h> #include <qmljsdebugclient/qmlprofilertraceclient.h>
#include <utils/styledbar.h> #include <utils/styledbar.h>

View File

@@ -34,7 +34,7 @@
#define TRACEWINDOW_H #define TRACEWINDOW_H
#include <qmljsdebugclient/qmlprofilertraceclient.h> #include <qmljsdebugclient/qmlprofilertraceclient.h>
#include "qmlprofilereventlist.h" #include <qmljsdebugclient/qmlprofilereventlist.h>
#include <QtCore/QPointer> #include <QtCore/QPointer>
#include <QtGui/QWidget> #include <QtGui/QWidget>
@@ -56,7 +56,7 @@ public:
void reset(QmlJsDebugClient::QDeclarativeDebugConnection *conn); void reset(QmlJsDebugClient::QDeclarativeDebugConnection *conn);
QmlProfilerEventList *getEventList() const; QmlJsDebugClient::QmlProfilerEventList *getEventList() const;
void setRecording(bool recording); void setRecording(bool recording);
bool isRecording() const; bool isRecording() const;
@@ -91,7 +91,7 @@ private:
QSize m_sizeHint; QSize m_sizeHint;
QDeclarativeView *m_view; QDeclarativeView *m_view;
QmlProfilerEventList *m_eventList; QmlJsDebugClient::QmlProfilerEventList *m_eventList;
}; };
} // namespace Internal } // namespace Internal