OSDN Git Service

QmlProfiler: Move EventList to qmljsdebugclient library
authorKai Koehne <kai.koehne@nokia.com>
Thu, 18 Aug 2011 14:10:33 +0000 (16:10 +0200)
committerKai Koehne <kai.koehne@nokia.com>
Mon, 22 Aug 2011 07:12:02 +0000 (09:12 +0200)
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>
src/libs/qmljsdebugclient/qmljsdebugclient-lib.pri
src/libs/qmljsdebugclient/qmlprofilereventlist.cpp [moved from src/plugins/qmlprofiler/qmlprofilereventlist.cpp with 96% similarity]
src/libs/qmljsdebugclient/qmlprofilereventlist.h [moved from src/plugins/qmlprofiler/qmlprofilereventlist.h with 91% similarity]
src/plugins/qmlprofiler/qmlprofiler.pro
src/plugins/qmlprofiler/qmlprofilereventview.h
src/plugins/qmlprofiler/qmlprofilertool.cpp
src/plugins/qmlprofiler/qmlprofilertool.h
src/plugins/qmlprofiler/timelineview.h
src/plugins/qmlprofiler/tracewindow.cpp
src/plugins/qmlprofiler/tracewindow.h

index 1eceea4..0f74211 100644 (file)
@@ -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 \
@@ -32,7 +32,6 @@
 
 #include "qmlprofilereventlist.h"
 
-#include <coreplugin/icore.h>
 #include <QtCore/QUrl>
 #include <QtCore/QHash>
 #include <QtCore/QtAlgorithms>
 #include <QtCore/QXmlStreamWriter>
 
 #include <QtCore/QTimer>
-#include <QtGui/QMainWindow>
-#include <QtGui/QMessageBox>
 
 #include <QDebug>
 
-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
 #ifndef QMLPROFILEREVENTLIST_H
 #define QMLPROFILEREVENTLIST_H
 
-#include <QObject>
+#include "qmlprofilereventtypes.h"
+#include "qmljsdebugclient_global.h"
+
 #include <QtCore/QHash>
-#include "qmljsdebugclient/qmlprofilereventtypes.h"
+#include <QtCore/QObject>
 
-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
index 231d4bf..107acdc 100644 (file)
@@ -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
index 60f5b13..952904f 100644 (file)
 
 #include <QTreeView>
 #include <qmljsdebugclient/qmlprofilereventtypes.h>
-#include "qmlprofilereventlist.h"
+#include <qmljsdebugclient/qmlprofilereventlist.h>
 
 namespace QmlProfiler {
 namespace Internal {
 
-typedef QHash<QString, QmlEventData *> QmlEventHash;
-typedef QList<QmlEventData *> QmlEventList;
+typedef QHash<QString, QmlJsDebugClient::QmlEventData *> QmlEventHash;
+typedef QList<QmlJsDebugClient::QmlEventData *> 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 );
index 0073854..bd4c650 100644 (file)
 #include "qmlprofilerplugin.h"
 #include "qmlprofilerconstants.h"
 #include "qmlprofilerattachdialog.h"
-#include "qmlprofilereventlist.h"
 #include "qmlprofilereventview.h"
 
 #include "tracewindow.h"
 #include "timelineview.h"
 
+#include <qmljsdebugclient/qmlprofilereventlist.h>
 #include <qmljsdebugclient/qdeclarativedebugclient.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(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();
+}
index 594f146..c8147a6 100644 (file)
@@ -90,6 +90,7 @@ private slots:
     void connectionStateChanged();
     void showSaveDialog();
     void showLoadDialog();
+    void showErrorDialog(const QString &error);
 
 private:
     void connectToClient();
index 8bf35ee..fd892ab 100644 (file)
@@ -35,7 +35,7 @@
 
 #include <QtDeclarative/QDeclarativeItem>
 #include <QtScript/QScriptValue>
-#include <qmlprofilereventlist.h>
+#include <qmljsdebugclient/qmlprofilereventlist.h>
 
 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<QmlProfilerEventList *>(eventList);
+        m_eventList = qobject_cast<QmlJsDebugClient::QmlProfilerEventList *>(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;
index 48403cf..2b3ab98 100644 (file)
@@ -33,9 +33,8 @@
 #include "tracewindow.h"
 
 #include "qmlprofilerplugin.h"
-#include "qmlprofilereventlist.h"
 
-#include <qmljsdebugclient/qdeclarativedebugclient.h>
+#include <qmljsdebugclient/qmlprofilereventlist.h>
 #include <qmljsdebugclient/qmlprofilertraceclient.h>
 #include <utils/styledbar.h>
 
index 04bbcab..c679590 100644 (file)
@@ -34,7 +34,7 @@
 #define TRACEWINDOW_H
 
 #include <qmljsdebugclient/qmlprofilertraceclient.h>
-#include "qmlprofilereventlist.h"
+#include <qmljsdebugclient/qmlprofilereventlist.h>
 
 #include <QtCore/QPointer>
 #include <QtGui/QWidget>
@@ -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