diff options
author | Christiaan Janssen <[email protected]> | 2012-02-24 10:47:17 +0100 |
---|---|---|
committer | Christiaan Janssen <[email protected]> | 2012-03-14 11:38:25 +0100 |
commit | b7304e2f2e533b767bcd1c02d8403e3d5fa63ddd (patch) | |
tree | 30bb48a69d7c6bd1c35bcdd359a757486f298368 /src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp | |
parent | d207165f6aa89ee95bd41c41a49d68cfa0b46444 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp')
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp new file mode 100644 index 00000000000..a12a6ccda5f --- /dev/null +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp @@ -0,0 +1,172 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation ([email protected]) +** +** +** 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 [email protected]. +** +**************************************************************************/ + +#include "qmlprofilerviewmanager.h" + +#include "qmlprofilertraceview.h" +#include "qmlprofilereventview.h" +#include "qmlprofilertool.h" +#include "qmlprofilerstatemanager.h" +#include "qmlprofilerdatamodel.h" + +#include <utils/qtcassert.h> +#include <utils/fancymainwindow.h> +#include <analyzerbase/analyzermanager.h> + + +#include <QDockWidget> + +using namespace Analyzer; + +namespace QmlProfiler { +namespace Internal { + +class QmlProfilerViewManager::QmlProfilerViewManagerPrivate { +public: + QmlProfilerViewManagerPrivate(QmlProfilerViewManager *qq) { Q_UNUSED(qq); } + + QmlProfilerTraceView *traceView; + QmlProfilerEventsWidget *eventsView; + QmlProfilerEventsWidget *v8profilerView; + QmlProfilerStateManager *profilerState; + QmlProfilerDataModel *profilerDataModel; + QmlProfilerTool *profilerTool; +}; + +QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent, + QmlProfilerTool *profilerTool, + QmlProfilerDataModel *model, + QmlProfilerStateManager *profilerState) + : QObject(parent), d(new QmlProfilerViewManagerPrivate(this)) +{ + setObjectName("QML Profiler View Manager"); + d->traceView = 0; + d->eventsView = 0; + d->v8profilerView = 0; + d->profilerState = profilerState; + d->profilerDataModel = model; + d->profilerTool = profilerTool; + createViews(); +} + +QmlProfilerViewManager::~QmlProfilerViewManager() +{ + delete d; +} + +//////////////////////////////////////////////////////////// +// Views +void QmlProfilerViewManager::createViews() +{ + QTC_ASSERT(d->profilerDataModel, return); + QTC_ASSERT(d->profilerState, return); + + Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow(); + + d->traceView = new QmlProfilerTraceView(mw, + d->profilerTool, + this, + d->profilerDataModel, + d->profilerState); + 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->profilerDataModel); + connect(d->eventsView, SIGNAL(gotoSourceLocation(QString,int,int)), this, + SIGNAL(gotoSourceLocation(QString,int,int))); + connect(d->eventsView, SIGNAL(showEventInTimeline(int)), d->traceView, + SLOT(selectNextEventWithId(int))); + connect(d->traceView, SIGNAL(selectedEventChanged(int)), d->eventsView, + SLOT(updateSelectedEvent(int))); + + d->v8profilerView = new QmlProfilerEventsWidget(mw, d->profilerTool, + this, d->profilerDataModel); + d->v8profilerView->switchToV8View(); + connect(d->v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)), + this, SIGNAL(gotoSourceLocation(QString,int,int))); + connect(d->v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)), + d->eventsView, SLOT(selectBySourceLocation(QString,int,int))); + connect(d->eventsView, SIGNAL(gotoSourceLocation(QString,int,int)), + d->v8profilerView, SLOT(selectBySourceLocation(QString,int,int))); + + QDockWidget *eventsDock = AnalyzerManager::createDockWidget + (d->profilerTool, tr("Events"), d->eventsView, Qt::BottomDockWidgetArea); + QDockWidget *timelineDock = AnalyzerManager::createDockWidget + (d->profilerTool, tr("Timeline"), d->traceView, Qt::BottomDockWidgetArea); + QDockWidget *v8profilerDock = AnalyzerManager::createDockWidget + (d->profilerTool, tr("JavaScript"), d->v8profilerView, Qt::BottomDockWidgetArea); + + eventsDock->show(); + timelineDock->show(); + v8profilerDock->show(); + + mw->splitDockWidget(mw->toolBarDockWidget(), eventsDock, Qt::Vertical); + mw->tabifyDockWidget(eventsDock, timelineDock); + mw->tabifyDockWidget(timelineDock, v8profilerDock); +} + +bool QmlProfilerViewManager::hasValidSelection() const +{ + return d->traceView->hasValidSelection(); +} + +qint64 QmlProfilerViewManager::selectionStart() const +{ + return d->traceView->selectionStart(); +} + +qint64 QmlProfilerViewManager::selectionEnd() const +{ + return d->traceView->selectionEnd(); +} + +bool QmlProfilerViewManager::hasGlobalStats() const +{ + return d->eventsView->hasGlobalStats(); +} + +void QmlProfilerViewManager::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd) +{ + d->eventsView->getStatisticsInRange(rangeStart, rangeEnd); +} + +void QmlProfilerViewManager::clear() +{ + d->traceView->clearDisplay(); + d->eventsView->clear(); + d->v8profilerView->clear(); +} + +} // namespace Internal +} // namespace QmlProfiler |