diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-01-04 17:20:13 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-01-06 14:28:20 +0000 |
commit | e4efb9bb3b5907a5ba2a6cde167c5a5051a84dac (patch) | |
tree | a92c118dd981f191d2c8c996ab07a984adb01df8 /src/plugins/qmlprofiler | |
parent | c16b843eccea038996cb21aec72ee1a5e99228c0 (diff) | |
download | qt-creator-e4efb9bb3b5907a5ba2a6cde167c5a5051a84dac.tar.gz |
QmlProfiler: Retrieve common actions from ActionManager
This removes the need to pass the QmlProfilerTool instance to all views.
QmlProfilerTool is exported so that we can access the common actions
from plugins.
Change-Id: Ie7072c23ef35763b729f4b87acce47ecbdb76e43
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmlprofiler')
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerconstants.h | 5 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp | 15 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerstatisticsview.h | 2 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertool.cpp | 17 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertool.h | 5 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertraceview.cpp | 12 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertraceview.h | 3 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp | 10 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerviewmanager.h | 1 |
9 files changed, 32 insertions, 38 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerconstants.h b/src/plugins/qmlprofiler/qmlprofilerconstants.h index 21f2268173..862b74d7d1 100644 --- a/src/plugins/qmlprofiler/qmlprofilerconstants.h +++ b/src/plugins/qmlprofiler/qmlprofilerconstants.h @@ -49,6 +49,11 @@ const char QmlProfilerToolId[] = "QmlProfiler"; const char QmlProfilerLocalActionId[] = "QmlProfiler.Local"; const char QmlProfilerRemoteActionId[] = "QmlProfiler.Remote"; +const char QmlProfilerLoadActionId[] = + "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.LoadQMLTrace"; +const char QmlProfilerSaveActionId[] = + "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.SaveQMLTrace"; + } // namespace Constants } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp b/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp index 328ad4526e..2da486dc93 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp @@ -117,7 +117,6 @@ public: QmlProfilerStatisticsView *q; - QmlProfilerTool *m_profilerTool; QmlProfilerStatisticsMainView *m_eventTree; QmlProfilerStatisticsRelativesView *m_eventChildren; QmlProfilerStatisticsRelativesView *m_eventParents; @@ -188,8 +187,8 @@ static void getSourceLocation(QStandardItem *infoItem, receiver(fileName, line, column); } -QmlProfilerStatisticsView::QmlProfilerStatisticsView(QWidget *parent, QmlProfilerTool *profilerTool, - QmlProfilerModelManager *profilerModelManager ) +QmlProfilerStatisticsView::QmlProfilerStatisticsView(QWidget *parent, + QmlProfilerModelManager *profilerModelManager) : QmlProfilerEventsView(parent), d(new QmlProfilerStatisticsViewPrivate(this)) { setObjectName(QLatin1String("QmlProfilerStatisticsView")); @@ -239,7 +238,6 @@ QmlProfilerStatisticsView::QmlProfilerStatisticsView(QWidget *parent, QmlProfile groupLayout->addWidget(splitterVertical); setLayout(groupLayout); - d->m_profilerTool = profilerTool; d->rangeStart = d->rangeEnd = -1; } @@ -278,12 +276,9 @@ void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev) QPoint position = ev->globalPos(); - if (d->m_profilerTool) { - QList <QAction *> commonActions = d->m_profilerTool->profilerContextMenuActions(); - foreach (QAction *act, commonActions) { - menu.addAction(act); - } - } + QList <QAction *> commonActions = QmlProfilerTool::profilerContextMenuActions(); + foreach (QAction *act, commonActions) + menu.addAction(act); if (mouseOnTable(position)) { menu.addSeparator(); diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsview.h b/src/plugins/qmlprofiler/qmlprofilerstatisticsview.h index a5665f97c7..e588418dc9 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatisticsview.h +++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsview.h @@ -81,7 +81,7 @@ class QmlProfilerStatisticsView : public QmlProfilerEventsView { Q_OBJECT public: - explicit QmlProfilerStatisticsView(QWidget *parent, QmlProfilerTool *profilerTool, + explicit QmlProfilerStatisticsView(QWidget *parent, QmlProfilerModelManager *profilerModelManager); ~QmlProfilerStatisticsView(); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index cdd8bbd308..617f3248af 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -178,13 +178,13 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent) options->menu()->setEnabled(true); QAction *act = d->m_loadQmlTrace = new QAction(tr("Load QML Trace"), options); - command = ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.LoadQMLTrace"); + command = ActionManager::registerAction(act, Constants::QmlProfilerLoadActionId); connect(act, &QAction::triggered, this, &QmlProfilerTool::showLoadDialog); options->addAction(command); act = d->m_saveQmlTrace = new QAction(tr("Save QML Trace"), options); d->m_saveQmlTrace->setEnabled(false); - command = ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.SaveQMLTrace"); + command = ActionManager::registerAction(act, Constants::QmlProfilerSaveActionId); connect(act, &QAction::triggered, this, &QmlProfilerTool::showSaveDialog); options->addAction(command); @@ -257,7 +257,6 @@ QWidget *QmlProfilerTool::createWidgets() d->m_viewContainer = new QmlProfilerViewManager(this, - this, d->m_profilerModelManager, d->m_profilerState); connect(d->m_viewContainer, &QmlProfilerViewManager::gotoSourceLocation, @@ -750,10 +749,18 @@ void QmlProfilerTool::profilerDataModelStateChanged() } } -QList <QAction *> QmlProfilerTool::profilerContextMenuActions() const +QList <QAction *> QmlProfilerTool::profilerContextMenuActions() { QList <QAction *> commonActions; - commonActions << d->m_loadQmlTrace << d->m_saveQmlTrace; + ActionManager *manager = ActionManager::instance(); + if (manager) { + Command *command = manager->command(Constants::QmlProfilerLoadActionId); + if (command) + commonActions << command->action(); + command = manager->command(Constants::QmlProfilerSaveActionId); + if (command) + commonActions << command->action(); + } return commonActions; } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index d12c77dd78..77c4ab9582 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -31,6 +31,7 @@ #ifndef QMLPROFILERTOOL_H #define QMLPROFILERTOOL_H +#include "qmlprofiler_global.h" #include "qmlprofilerconstants.h" #include "qmldebug/qmlprofilereventtypes.h" @@ -44,7 +45,7 @@ QT_END_NAMESPACE namespace QmlProfiler { namespace Internal { -class QmlProfilerTool : public QObject +class QMLPROFILER_EXPORT QmlProfilerTool : public QObject { Q_OBJECT @@ -59,7 +60,7 @@ public: bool prepareTool(); void startRemoteTool(); - QList <QAction *> profilerContextMenuActions() const; + static QList <QAction *> profilerContextMenuActions(); // display dialogs / log output static QMessageBox *requestMessageBox(); diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index 8ee5f35d67..2d62faab8e 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -77,7 +77,6 @@ public: QmlProfilerTraceViewPrivate(QmlProfilerTraceView *qq) : q(qq) {} QmlProfilerTraceView *q; - QmlProfilerTool *m_profilerTool; QmlProfilerViewManager *m_viewContainer; QSize m_sizeHint; @@ -90,7 +89,8 @@ public: Timeline::TimelineZoomControl *m_zoomControl; }; -QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerModelManager *modelManager) +QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManager *container, + QmlProfilerModelManager *modelManager) : QWidget(parent), d(new QmlProfilerTraceViewPrivate(this)) { setObjectName(QLatin1String("QML Profiler")); @@ -126,9 +126,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *pro groupLayout->addWidget(new Core::FindToolBarPlaceHolder(this)); setLayout(groupLayout); - d->m_profilerTool = profilerTool; d->m_viewContainer = container; - d->m_modelProxy = new Timeline::TimelineModelAggregator(modelManager->notesModel(), this); d->m_modelManager = modelManager; @@ -241,11 +239,7 @@ void QmlProfilerTraceView::showContextMenu(QPoint position) QMenu menu; QAction *viewAllAction = 0; - QmlProfilerTool *profilerTool = qobject_cast<QmlProfilerTool *>(d->m_profilerTool); - - if (profilerTool) - menu.addActions(profilerTool->profilerContextMenuActions()); - + menu.addActions(QmlProfilerTool::profilerContextMenuActions()); menu.addSeparator(); QAction *getLocalStatsAction = menu.addAction(tr("Limit Statistics Pane to Current Range")); diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.h b/src/plugins/qmlprofiler/qmlprofilertraceview.h index c696ed45d1..918e21468f 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.h +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.h @@ -53,8 +53,7 @@ class QmlProfilerTraceView : public QWidget Q_OBJECT public: - explicit QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *profilerTool, - QmlProfilerViewManager *container, + explicit QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManager *container, QmlProfilerModelManager *modelManager); ~QmlProfilerTraceView(); diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp index b926f52909..1dbc109f0d 100644 --- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp @@ -57,11 +57,9 @@ public: QmlProfilerStatisticsView *eventsView; QmlProfilerStateManager *profilerState; QmlProfilerModelManager *profilerModelManager; - QmlProfilerTool *profilerTool; }; QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent, - QmlProfilerTool *profilerTool, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState) : QObject(parent), d(new QmlProfilerViewManagerPrivate(this)) @@ -71,7 +69,6 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent, d->eventsView = 0; d->profilerState = profilerState; d->profilerModelManager = modelManager; - d->profilerTool = profilerTool; createViews(); } @@ -88,15 +85,12 @@ void QmlProfilerViewManager::createViews() Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow(); - d->traceView = new QmlProfilerTraceView(mw, - d->profilerTool, - this, - d->profilerModelManager); + d->traceView = new QmlProfilerTraceView(mw, this, d->profilerModelManager); d->traceView->setWindowTitle(tr("Timeline")); connect(d->traceView, &QmlProfilerTraceView::gotoSourceLocation, this, &QmlProfilerViewManager::gotoSourceLocation); - d->eventsView = new QmlProfilerStatisticsView(mw, d->profilerTool, d->profilerModelManager); + d->eventsView = new QmlProfilerStatisticsView(mw, d->profilerModelManager); d->eventsView->setWindowTitle(tr("Statistics")); connect(d->eventsView, &QmlProfilerStatisticsView::gotoSourceLocation, this, &QmlProfilerViewManager::gotoSourceLocation); diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.h b/src/plugins/qmlprofiler/qmlprofilerviewmanager.h index 144009e7eb..b31849b67e 100644 --- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.h @@ -46,7 +46,6 @@ class QmlProfilerViewManager : public QObject Q_OBJECT public: explicit QmlProfilerViewManager(QObject *parent, - QmlProfilerTool *profilerTool, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState); ~QmlProfilerViewManager(); |