QmlProfiler: Refactor

The code of the qmlprofiler client has become a bit too complex,
this patch reorganizes the modules in a more sensible way,
having the modules communicate with each other through a
state machine instead of the excess of signals and slots
from before.

Change-Id: I76f7313779888a1bd07a1cdb1acbf2e47aacf42a
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Christiaan Janssen
2012-02-24 10:47:17 +01:00
parent d207165f6a
commit b7304e2f2e
47 changed files with 4742 additions and 3896 deletions

View File

@@ -0,0 +1,158 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** 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.
**
** 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef QMLPROFILERTRACEVIEW_H
#define QMLPROFILERTRACEVIEW_H
#include <QDeclarativeView>
namespace Analyzer {
class IAnalyzerTool;
}
namespace QmlProfiler {
namespace Internal {
class QmlProfilerStateManager;
class QmlProfilerViewManager;
class QmlProfilerDataModel;
// capture mouse wheel events
class MouseWheelResizer : public QObject {
Q_OBJECT
public:
MouseWheelResizer(QObject *parent=0):QObject(parent){}
protected:
bool eventFilter(QObject *obj, QEvent *event);
signals:
void mouseWheelMoved(int x, int y, int delta);
};
// centralized zoom control
class ZoomControl : public QObject {
Q_OBJECT
public:
ZoomControl(QObject *parent=0):QObject(parent),m_startTime(0),m_endTime(0) {}
~ZoomControl(){}
Q_INVOKABLE void setRange(qint64 startTime, qint64 endTime);
Q_INVOKABLE qint64 startTime() { return m_startTime; }
Q_INVOKABLE qint64 endTime() { return m_endTime; }
signals:
void rangeChanged();
private:
qint64 m_startTime;
qint64 m_endTime;
};
class ScrollableDeclarativeView : public QDeclarativeView
{
Q_OBJECT
public:
explicit ScrollableDeclarativeView(QWidget *parent = 0);
~ScrollableDeclarativeView();
protected:
void scrollContentsBy(int dx, int dy);
};
class QmlProfilerTraceView : public QWidget
{
Q_OBJECT
public:
explicit QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerDataModel *model, QmlProfilerStateManager *profilerState);
~QmlProfilerTraceView();
void reset();
bool hasValidSelection() const;
qint64 selectionStart() const;
qint64 selectionEnd() const;
public slots:
void clearDisplay();
void selectNextEventWithId(int eventId);
private slots:
void updateCursorPosition();
void toggleRangeMode(bool);
void updateRangeButton();
void toggleLockMode(bool);
void updateLockButton();
void setZoomLevel(int zoomLevel);
void updateRange();
void mouseWheelMoved(int mouseX, int mouseY, int wheelDelta);
void updateToolTip(const QString &text);
void updateVerticalScroll(int newPosition);
void profilerDataModelStateChanged();
protected:
virtual void resizeEvent(QResizeEvent *event);
private slots:
void profilerStateChanged();
void clientRecordingChanged();
void serverRecordingChanged();
signals:
void gotoSourceLocation(const QString &fileUrl, int lineNumber, int columNumber);
void selectedEventChanged(int eventId);
void jumpToPrev();
void jumpToNext();
void rangeModeChanged(bool);
void lockModeChanged(bool);
void enableToolbar(bool);
void zoomLevelChanged(int);
private:
void contextMenuEvent(QContextMenuEvent *);
QWidget *createToolbar();
QWidget *createZoomToolbar();
void setRecording(bool recording);
void setAppKilled();
private:
class QmlProfilerTraceViewPrivate;
QmlProfilerTraceViewPrivate *d;
};
} // namespace Internal
} // namespace QmlProfiler
#endif // QMLPROFILERTRACEVIEW_H