From 749534ea766fb86af8e6deeb17e2900b1eb43a58 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 18 Aug 2011 16:10:33 +0200 Subject: [PATCH] QmlProfiler: Move EventList to qmljsdebugclient library Change-Id: Icbd24ffeb51db0f098d8fe9c62a0a889a722f760 Reviewed-on: http://codereview.qt.nokia.com/3222 Reviewed-by: Qt Sanity Bot Reviewed-by: Christiaan Janssen --- src/libs/qmljsdebugclient/qmljsdebugclient-lib.pri | 6 ++-- .../qmljsdebugclient}/qmlprofilereventlist.cpp | 32 +++++----------------- .../qmljsdebugclient}/qmlprofilereventlist.h | 19 +++++++------ src/plugins/qmlprofiler/qmlprofiler.pro | 6 ++-- src/plugins/qmlprofiler/qmlprofilereventview.h | 10 +++---- src/plugins/qmlprofiler/qmlprofilertool.cpp | 16 ++++++++++- src/plugins/qmlprofiler/qmlprofilertool.h | 1 + src/plugins/qmlprofiler/timelineview.h | 10 +++---- src/plugins/qmlprofiler/tracewindow.cpp | 3 +- src/plugins/qmlprofiler/tracewindow.h | 6 ++-- 10 files changed, 53 insertions(+), 56 deletions(-) rename src/{plugins/qmlprofiler => libs/qmljsdebugclient}/qmlprofilereventlist.cpp (96%) rename src/{plugins/qmlprofiler => libs/qmljsdebugclient}/qmlprofilereventlist.h (91%) diff --git a/src/libs/qmljsdebugclient/qmljsdebugclient-lib.pri b/src/libs/qmljsdebugclient/qmljsdebugclient-lib.pri index 1eceea45d3..0f74211e9d 100644 --- a/src/libs/qmljsdebugclient/qmljsdebugclient-lib.pri +++ b/src/libs/qmljsdebugclient/qmljsdebugclient-lib.pri @@ -12,13 +12,15 @@ HEADERS += \ $$PWD/qdeclarativedebugclient.h \ $$PWD/qmljsdebugclient_global.h \ $$PWD/qmlprofilertraceclient.h \ - $$PWD/qmlprofilereventtypes.h + $$PWD/qmlprofilereventtypes.h \ + $$PWD/qmlprofilereventlist.h SOURCES += \ $$PWD/qdeclarativeenginedebug.cpp \ $$PWD/qpacketprotocol.cpp \ $$PWD/qdeclarativedebugclient.cpp \ - $$PWD/qmlprofilertraceclient.cpp + $$PWD/qmlprofilertraceclient.cpp \ + $$PWD/qmlprofilereventlist.cpp OTHER_FILES += \ $$PWD/qmljsdebugclient.pri \ diff --git a/src/plugins/qmlprofiler/qmlprofilereventlist.cpp b/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp similarity index 96% rename from src/plugins/qmlprofiler/qmlprofilereventlist.cpp rename to src/libs/qmljsdebugclient/qmlprofilereventlist.cpp index dd05407dbc..10fc09ca12 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventlist.cpp +++ b/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp @@ -32,7 +32,6 @@ #include "qmlprofilereventlist.h" -#include #include #include #include @@ -44,13 +43,10 @@ #include #include -#include -#include #include -namespace QmlProfiler { -namespace Internal { +namespace QmlJsDebugClient { #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) { - showErrorDialog(tr("No data to save")); + emit error(tr("No data to save")); return; } QFile file(filename); 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; } @@ -659,7 +655,7 @@ void QmlProfilerEventList::load() QFile file(filename); 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; } @@ -761,7 +757,7 @@ void QmlProfilerEventList::load() file.close(); if (stream.hasError()) { - showErrorDialog(tr("Error while parsing %1").arg(filename)); + emit error(tr("Error while parsing %1").arg(filename)); clear(); return; } @@ -794,19 +790,6 @@ void QmlProfilerEventList::load() 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 { return d->m_startTimeSortedList[index].startTime; @@ -845,5 +828,4 @@ QString QmlProfilerEventList::getDetails(int index) const { } -} // namespace Internal -} // namespace QmlProfiler +} // namespace QmlJsDebugClient diff --git a/src/plugins/qmlprofiler/qmlprofilereventlist.h b/src/libs/qmljsdebugclient/qmlprofilereventlist.h similarity index 91% rename from src/plugins/qmlprofiler/qmlprofilereventlist.h rename to src/libs/qmljsdebugclient/qmlprofilereventlist.h index 767da098d7..d65f8fef6c 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventlist.h +++ b/src/libs/qmljsdebugclient/qmlprofilereventlist.h @@ -33,14 +33,15 @@ #ifndef QMLPROFILEREVENTLIST_H #define QMLPROFILEREVENTLIST_H -#include +#include "qmlprofilereventtypes.h" +#include "qmljsdebugclient_global.h" + #include -#include "qmljsdebugclient/qmlprofilereventtypes.h" +#include -namespace QmlProfiler { -namespace Internal { +namespace QmlJsDebugClient { -struct QmlEventData +struct QMLJSDEBUGCLIENT_EXPORT QmlEventData { QString displayname; QString filename; @@ -70,7 +71,7 @@ enum ParsingStatus { DoneStatus = 5 }; -class QmlProfilerEventList : public QObject +class QMLJSDEBUGCLIENT_EXPORT QmlProfilerEventList : public QObject { Q_OBJECT public: @@ -105,13 +106,14 @@ signals: void dataReady(); void countChanged(); void parsingStatusChanged(); + void error(const QString &error); public slots: void clear(); void addRangedEvent(int type, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line); void complete(); - void save(const QString &filename) const; + void save(const QString &filename); void load(const QString &filename); void setFilename(const QString &filename); void load(); @@ -132,7 +134,6 @@ private: }; -} // namespace Internal -} // namespace QmlProfiler +} // namespace QmlJsDebugClient #endif // QMLPROFILEREVENTLIST_H diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index 231d4bf36c..107acdcfc5 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -27,8 +27,7 @@ SOURCES += \ codaqmlprofilerrunner.cpp \ remotelinuxqmlprofilerrunner.cpp \ qmlprofilereventview.cpp \ - qmlprofilerruncontrolfactory.cpp \ - qmlprofilereventlist.cpp + qmlprofilerruncontrolfactory.cpp HEADERS += \ qmlprofilerconstants.h \ @@ -44,8 +43,7 @@ HEADERS += \ codaqmlprofilerrunner.h \ remotelinuxqmlprofilerrunner.h \ qmlprofilereventview.h \ - qmlprofilerruncontrolfactory.h\ - qmlprofilereventlist.h + qmlprofilerruncontrolfactory.h RESOURCES += \ qml/qml.qrc diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h index 60f5b13acc..952904f12d 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.h +++ b/src/plugins/qmlprofiler/qmlprofilereventview.h @@ -35,13 +35,13 @@ #include #include -#include "qmlprofilereventlist.h" +#include namespace QmlProfiler { namespace Internal { -typedef QHash QmlEventHash; -typedef QList QmlEventList; +typedef QHash QmlEventHash; +typedef QList QmlEventList; enum ItemRole { LocationRole = Qt::UserRole+1, @@ -77,10 +77,10 @@ public: MaxViewTypes }; - explicit QmlProfilerEventsView(QWidget *parent, QmlProfilerEventList *model); + explicit QmlProfilerEventsView(QWidget *parent, QmlJsDebugClient::QmlProfilerEventList *model); ~QmlProfilerEventsView(); - void setEventStatisticsModel( QmlProfilerEventList *model ); + void setEventStatisticsModel(QmlJsDebugClient::QmlProfilerEventList *model); void setFieldViewable(Fields field, bool show); void setViewType(ViewTypes type); void setShowAnonymousEvents( bool showThem ); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 00738542f2..bd4c650580 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -35,12 +35,12 @@ #include "qmlprofilerplugin.h" #include "qmlprofilerconstants.h" #include "qmlprofilerattachdialog.h" -#include "qmlprofilereventlist.h" #include "qmlprofilereventview.h" #include "tracewindow.h" #include "timelineview.h" +#include #include #include @@ -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(timeChanged(qreal)), this, SLOT(updateTimer(qreal))); 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->setViewType(QmlProfilerEventsView::EventsView); @@ -582,3 +583,16 @@ void QmlProfilerTool::showLoadDialog() 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(); +} diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 594f146585..c8147a6e41 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -90,6 +90,7 @@ private slots: void connectionStateChanged(); void showSaveDialog(); void showLoadDialog(); + void showErrorDialog(const QString &error); private: void connectToClient(); diff --git a/src/plugins/qmlprofiler/timelineview.h b/src/plugins/qmlprofiler/timelineview.h index 8bf35ee696..fd892ab31b 100644 --- a/src/plugins/qmlprofiler/timelineview.h +++ b/src/plugins/qmlprofiler/timelineview.h @@ -35,7 +35,7 @@ #include #include -#include +#include namespace QmlProfiler { namespace Internal { @@ -81,10 +81,10 @@ public: qreal cachedProgress() const; - QmlProfilerEventList *eventList() const { return m_eventList; } + QmlJsDebugClient::QmlProfilerEventList *eventList() const { return m_eventList; } void setEventList(QObject *eventList) { - m_eventList = qobject_cast(eventList); + m_eventList = qobject_cast(eventList); emit eventListChanged(m_eventList); } @@ -100,7 +100,7 @@ signals: void endTimeChanged(qint64 arg); void startXChanged(qreal arg); void totalWidthChanged(qreal arg); - void eventListChanged(QmlProfilerEventList *list); + void eventListChanged(QmlJsDebugClient::QmlProfilerEventList *list); void cachedProgressChanged(); void cacheReady(); @@ -157,7 +157,7 @@ private: int prevMin; int prevMax; - QmlProfilerEventList *m_eventList; + QmlJsDebugClient::QmlProfilerEventList *m_eventList; qreal m_totalWidth; int m_lastCachedIndex; diff --git a/src/plugins/qmlprofiler/tracewindow.cpp b/src/plugins/qmlprofiler/tracewindow.cpp index 48403cf649..2b3ab98e57 100644 --- a/src/plugins/qmlprofiler/tracewindow.cpp +++ b/src/plugins/qmlprofiler/tracewindow.cpp @@ -33,9 +33,8 @@ #include "tracewindow.h" #include "qmlprofilerplugin.h" -#include "qmlprofilereventlist.h" -#include +#include #include #include diff --git a/src/plugins/qmlprofiler/tracewindow.h b/src/plugins/qmlprofiler/tracewindow.h index 04bbcab261..c679590a73 100644 --- a/src/plugins/qmlprofiler/tracewindow.h +++ b/src/plugins/qmlprofiler/tracewindow.h @@ -34,7 +34,7 @@ #define TRACEWINDOW_H #include -#include "qmlprofilereventlist.h" +#include #include #include @@ -56,7 +56,7 @@ public: void reset(QmlJsDebugClient::QDeclarativeDebugConnection *conn); - QmlProfilerEventList *getEventList() const; + QmlJsDebugClient::QmlProfilerEventList *getEventList() const; void setRecording(bool recording); bool isRecording() const; @@ -91,7 +91,7 @@ private: QSize m_sizeHint; QDeclarativeView *m_view; - QmlProfilerEventList *m_eventList; + QmlJsDebugClient::QmlProfilerEventList *m_eventList; }; } // namespace Internal -- 2.11.0