forked from qt-creator/qt-creator
QmlProfiler: cleanup QmlProfilerTraceView
Remove some unnecessary code and consolidate things. Change-Id: I3f6c971b84368013a60a7a7fa9545480b0cd551b Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -179,7 +179,7 @@ Rectangle {
|
||||
|
||||
ButtonsBar {
|
||||
id: buttonsBar
|
||||
enabled: false
|
||||
enabled: timelineModelAggregator.height > 0
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
width: 150
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.1
|
||||
import Monitor 1.0
|
||||
import "Overview.js" as Plotter
|
||||
|
||||
Canvas {
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.1
|
||||
import Monitor 1.0
|
||||
|
||||
Item {
|
||||
id: rangeDetails
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.1
|
||||
import Monitor 1.0
|
||||
|
||||
Item {
|
||||
id: selectionRangeDetails
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.2
|
||||
import Monitor 1.0
|
||||
import TimelineRenderer 1.0
|
||||
import QtQml.Models 2.1
|
||||
|
||||
ScrollView {
|
||||
|
||||
@@ -102,7 +102,6 @@ QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateMan
|
||||
this, SLOT(profilerStateChanged()));
|
||||
|
||||
updateDisplay();
|
||||
connect(parent,SIGNAL(resized()),this,SLOT(reposition()));
|
||||
}
|
||||
|
||||
QmlProfilerStateWidget::~QmlProfilerStateWidget()
|
||||
|
||||
@@ -128,8 +128,6 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
d->m_clearButton = 0;
|
||||
d->m_timeLabel = 0;
|
||||
|
||||
qmlRegisterType<TimelineRenderer>("Monitor", 1, 0,"TimelineRenderer");
|
||||
|
||||
d->m_profilerState = new QmlProfilerStateManager(this);
|
||||
connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged()));
|
||||
connect(d->m_profilerState, SIGNAL(clientRecordingChanged()), this, SLOT(clientRecordingChanged()));
|
||||
|
||||
@@ -70,11 +70,6 @@ class QmlProfilerTraceView::QmlProfilerTraceViewPrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerTraceViewPrivate(QmlProfilerTraceView *qq) : q(qq) {}
|
||||
~QmlProfilerTraceViewPrivate()
|
||||
{
|
||||
delete m_mainView;
|
||||
}
|
||||
|
||||
QmlProfilerTraceView *q;
|
||||
|
||||
QmlProfilerStateManager *m_profilerState;
|
||||
@@ -104,6 +99,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
||||
groupLayout->setContentsMargins(0, 0, 0, 0);
|
||||
groupLayout->setSpacing(0);
|
||||
|
||||
qmlRegisterType<TimelineRenderer>("TimelineRenderer", 1, 0, "TimelineRenderer");
|
||||
qmlRegisterType<TimelineZoomControl>();
|
||||
qmlRegisterType<TimelineModel>();
|
||||
qmlRegisterType<TimelineNotesModel>();
|
||||
@@ -113,8 +109,6 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
||||
QWidget *mainViewContainer = QWidget::createWindowContainer(d->m_mainView);
|
||||
mainViewContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
enableToolbar(false);
|
||||
|
||||
groupLayout->addWidget(mainViewContainer);
|
||||
setLayout(groupLayout);
|
||||
|
||||
@@ -122,20 +116,9 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
||||
d->m_viewContainer = container;
|
||||
|
||||
d->m_modelProxy = new TimelineModelAggregator(modelManager->notesModel(), this);
|
||||
setModelManager(modelManager);
|
||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("timelineModelAggregator"),
|
||||
d->m_modelProxy);
|
||||
d->m_profilerState = profilerState;
|
||||
|
||||
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
||||
setMinimumHeight(170);
|
||||
}
|
||||
|
||||
void QmlProfilerTraceView::setModelManager(QmlProfilerModelManager *modelManager)
|
||||
{
|
||||
d->m_modelManager = modelManager;
|
||||
connect(modelManager,SIGNAL(dataAvailable()),
|
||||
d->m_modelProxy,SIGNAL(dataAvailable()));
|
||||
|
||||
connect(modelManager,SIGNAL(dataAvailable()), d->m_modelProxy,SIGNAL(dataAvailable()));
|
||||
|
||||
// external models pushed on top
|
||||
foreach (QmlProfilerTimelineModel *timelineModel,
|
||||
@@ -143,37 +126,37 @@ void QmlProfilerTraceView::setModelManager(QmlProfilerModelManager *modelManager
|
||||
d->m_modelProxy->addModel(timelineModel);
|
||||
}
|
||||
|
||||
d->m_modelProxy->addModel(new QmlProfilerAnimationsModel(modelManager,
|
||||
d->m_modelProxy));
|
||||
d->m_modelProxy->addModel(new QmlProfilerAnimationsModel(modelManager, d->m_modelProxy));
|
||||
|
||||
for (int i = 0; i < QmlDebug::MaximumRangeType; ++i)
|
||||
d->m_modelProxy->addModel(new QmlProfilerRangeModel(modelManager, (QmlDebug::RangeType)i,
|
||||
d->m_modelProxy));
|
||||
|
||||
// Connect this last so that it's executed after the models have updated their data.
|
||||
connect(modelManager->qmlModel(), SIGNAL(changed()),
|
||||
d->m_modelProxy, SIGNAL(stateChanged()));
|
||||
connect(d->m_modelManager, SIGNAL(stateChanged()),
|
||||
this, SLOT(profilerDataModelStateChanged()));
|
||||
}
|
||||
connect(modelManager->qmlModel(), SIGNAL(changed()), d->m_modelProxy, SIGNAL(stateChanged()));
|
||||
connect(d->m_modelManager, SIGNAL(stateChanged()), this, SLOT(profilerDataModelStateChanged()));
|
||||
|
||||
d->m_profilerState = profilerState;
|
||||
|
||||
QmlProfilerTraceView::~QmlProfilerTraceView()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
||||
setMinimumHeight(170);
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Initialize widgets
|
||||
void QmlProfilerTraceView::reset()
|
||||
{
|
||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("zoomControl"), d->m_zoomControl);
|
||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("timelineModelAggregator"),
|
||||
d->m_modelProxy);
|
||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("zoomControl"),
|
||||
d->m_zoomControl);
|
||||
d->m_mainView->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/MainView.qml")));
|
||||
|
||||
QQuickItem *rootObject = d->m_mainView->rootObject();
|
||||
connect(rootObject, SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
|
||||
}
|
||||
|
||||
QmlProfilerTraceView::~QmlProfilerTraceView()
|
||||
{
|
||||
delete d->m_mainView;
|
||||
delete d;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
bool QmlProfilerTraceView::hasValidSelection() const
|
||||
{
|
||||
@@ -183,12 +166,6 @@ bool QmlProfilerTraceView::hasValidSelection() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void QmlProfilerTraceView::enableToolbar(bool enable)
|
||||
{
|
||||
QMetaObject::invokeMethod(d->m_mainView->rootObject(), "enableButtonsBar",
|
||||
Q_ARG(QVariant,QVariant(enable)));
|
||||
}
|
||||
|
||||
qint64 QmlProfilerTraceView::selectionStart() const
|
||||
{
|
||||
QQuickItem *rootObject = d->m_mainView->rootObject();
|
||||
@@ -249,13 +226,6 @@ void QmlProfilerTraceView::updateCursorPosition()
|
||||
emit typeSelected(rootObject->property("typeId").toInt());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
void QmlProfilerTraceView::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
emit resized();
|
||||
}
|
||||
|
||||
void QmlProfilerTraceView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
d->m_zoomControl->setWindowLocked(true);
|
||||
@@ -325,12 +295,10 @@ void QmlProfilerTraceView::profilerDataModelStateChanged()
|
||||
case QmlProfilerDataState::Empty: break;
|
||||
case QmlProfilerDataState::ClearingData:
|
||||
d->m_mainView->hide();
|
||||
enableToolbar(false);
|
||||
break;
|
||||
case QmlProfilerDataState::AcquiringData: break;
|
||||
case QmlProfilerDataState::ProcessingData: break;
|
||||
case QmlProfilerDataState::Done:
|
||||
enableToolbar(true);
|
||||
d->m_mainView->show();
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -46,17 +46,17 @@ namespace Internal {
|
||||
class QmlProfilerStateManager;
|
||||
class QmlProfilerViewManager;
|
||||
|
||||
|
||||
class QmlProfilerTraceView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState);
|
||||
explicit QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool,
|
||||
QmlProfilerViewManager *container,
|
||||
QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerStateManager *profilerState);
|
||||
~QmlProfilerTraceView();
|
||||
|
||||
void reset();
|
||||
|
||||
bool hasValidSelection() const;
|
||||
qint64 selectionStart() const;
|
||||
qint64 selectionEnd() const;
|
||||
@@ -72,7 +72,6 @@ private slots:
|
||||
void profilerDataModelStateChanged();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||
@@ -80,15 +79,10 @@ protected:
|
||||
signals:
|
||||
void gotoSourceLocation(const QString &fileUrl, int lineNumber, int columNumber);
|
||||
void typeSelected(int typeId);
|
||||
void resized();
|
||||
|
||||
private:
|
||||
void enableToolbar(bool);
|
||||
|
||||
private:
|
||||
class QmlProfilerTraceViewPrivate;
|
||||
QmlProfilerTraceViewPrivate *d;
|
||||
void setModelManager(QmlProfilerModelManager *modelManager);
|
||||
};
|
||||
|
||||
class QmlProfilerQuickView : public QQuickView {
|
||||
|
||||
@@ -100,8 +100,6 @@ void QmlProfilerViewManager::createViews()
|
||||
d->traceView->setWindowTitle(tr("Timeline"));
|
||||
connect(d->traceView, SIGNAL(gotoSourceLocation(QString,int,int)),
|
||||
this, SIGNAL(gotoSourceLocation(QString,int,int)));
|
||||
d->traceView->reset();
|
||||
|
||||
|
||||
d->eventsView = new QmlProfilerEventsWidget(mw, d->profilerTool, this,
|
||||
d->profilerModelManager);
|
||||
|
||||
Reference in New Issue
Block a user