| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** Copyright (C) 2015 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: http://www.qt.io/licensing
 | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** This file is part of Qt Creator. | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** a written agreement between you and The Qt Company.  For licensing terms and | 
					
						
							|  |  |  | ** conditions see http://www.qt.io/terms-conditions.  For further information
 | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** use the contact form at http://www.qt.io/contact-us.
 | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** General Public License version 2.1 or version 3 as published by the Free | 
					
						
							|  |  |  | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | 
					
						
							|  |  |  | ** LICENSE.LGPLv3 included in the packaging of this file.  Please review the | 
					
						
							|  |  |  | ** following information to ensure the GNU Lesser General Public License | 
					
						
							|  |  |  | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
 | 
					
						
							|  |  |  | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2015-01-14 18:07:15 +01:00
										 |  |  | ** In addition, as a special exception, The Qt Company gives you certain additional | 
					
						
							|  |  |  | ** rights.  These rights are described in The Qt Company LGPL Exception | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | #include "qmlprofilertool.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | #include "qmlprofilerstatemanager.h"
 | 
					
						
							| 
									
										
										
										
											2015-07-01 18:11:54 +02:00
										 |  |  | #include "qmlprofilerruncontrol.h"
 | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | #include "qmlprofilerconstants.h"
 | 
					
						
							|  |  |  | #include "qmlprofilerattachdialog.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | #include "qmlprofilerviewmanager.h"
 | 
					
						
							|  |  |  | #include "qmlprofilerclientmanager.h"
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | #include "qmlprofilermodelmanager.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | #include "qmlprofilerdetailsrewriter.h"
 | 
					
						
							| 
									
										
										
										
											2014-10-27 17:41:22 +01:00
										 |  |  | #include "qmlprofilernotesmodel.h"
 | 
					
						
							| 
									
										
										
										
											2015-08-28 12:50:46 +02:00
										 |  |  | #include "qmlprofilerrunconfigurationaspect.h"
 | 
					
						
							|  |  |  | #include "qmlprofilersettings.h"
 | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  | #include "qmlprofilerplugin.h"
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <analyzerbase/analyzermanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-09-14 13:12:25 +02:00
										 |  |  | #include <analyzerbase/analyzerruncontrol.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-20 12:43:29 +02:00
										 |  |  | #include <utils/fancymainwindow.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | #include <utils/fileinprojectfinder.h>
 | 
					
						
							| 
									
										
										
										
											2011-04-14 17:19:28 +02:00
										 |  |  | #include <utils/qtcassert.h>
 | 
					
						
							| 
									
										
										
										
											2015-10-19 12:55:13 +02:00
										 |  |  | #include <utils/themehelper.h>
 | 
					
						
							| 
									
										
										
										
											2013-01-29 18:00:30 +01:00
										 |  |  | #include <projectexplorer/environmentaspect.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | #include <projectexplorer/projectexplorer.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/project.h>
 | 
					
						
							| 
									
										
										
										
											2011-04-01 13:48:10 +02:00
										 |  |  | #include <projectexplorer/target.h>
 | 
					
						
							| 
									
										
										
										
											2011-10-28 16:32:34 +02:00
										 |  |  | #include <projectexplorer/session.h>
 | 
					
						
							| 
									
										
										
										
											2013-04-17 11:10:45 +02:00
										 |  |  | #include <projectexplorer/kitinformation.h>
 | 
					
						
							| 
									
										
										
										
											2013-01-28 12:56:56 +01:00
										 |  |  | #include <projectexplorer/localapplicationrunconfiguration.h>
 | 
					
						
							| 
									
										
										
										
											2014-09-26 09:14:03 +02:00
										 |  |  | #include <texteditor/texteditor.h>
 | 
					
						
							| 
									
										
										
										
											2011-12-27 22:41:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | #include <coreplugin/coreconstants.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | #include <coreplugin/editormanager/editormanager.h>
 | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  | #include <coreplugin/find/findplugin.h>
 | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2011-07-27 11:49:39 +02:00
										 |  |  | #include <coreplugin/messagemanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-09-14 13:26:19 +02:00
										 |  |  | #include <coreplugin/helpmanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | #include <coreplugin/modemanager.h>
 | 
					
						
							|  |  |  | #include <coreplugin/imode.h>
 | 
					
						
							|  |  |  | #include <coreplugin/actionmanager/command.h>
 | 
					
						
							|  |  |  | #include <coreplugin/actionmanager/actionmanager.h>
 | 
					
						
							|  |  |  | #include <coreplugin/actionmanager/actioncontainer.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  | #include <qtsupport/qtkitinformation.h>
 | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QApplication>
 | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QHBoxLayout>
 | 
					
						
							|  |  |  | #include <QLabel>
 | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | #include <QLineEdit>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QMenu>
 | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2013-04-17 17:58:27 +02:00
										 |  |  | #include <QTcpServer>
 | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  | #include <QTime>
 | 
					
						
							|  |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | #include <QToolButton>
 | 
					
						
							| 
									
										
										
										
											2011-04-08 13:05:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | using namespace Core; | 
					
						
							|  |  |  | using namespace Core::Constants; | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | using namespace Analyzer; | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | using namespace Analyzer::Constants; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | using namespace QmlProfiler::Constants; | 
					
						
							| 
									
										
										
										
											2012-04-18 12:06:10 +02:00
										 |  |  | using namespace QmlDebug; | 
					
						
							| 
									
										
										
										
											2011-09-14 13:12:25 +02:00
										 |  |  | using namespace ProjectExplorer; | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | namespace QmlProfiler { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | class QmlProfilerTool::QmlProfilerToolPrivate | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     QmlProfilerStateManager *m_profilerState; | 
					
						
							|  |  |  |     QmlProfilerClientManager *m_profilerConnections; | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     QmlProfilerModelManager *m_profilerModelManager; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QmlProfilerViewManager *m_viewContainer; | 
					
						
							| 
									
										
										
										
											2011-04-01 13:48:10 +02:00
										 |  |  |     Utils::FileInProjectFinder m_projectFinder; | 
					
						
							| 
									
										
										
										
											2011-04-06 12:26:19 +02:00
										 |  |  |     QToolButton *m_recordButton; | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     QMenu *m_recordFeaturesMenu; | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-24 18:19:08 +02:00
										 |  |  |     QToolButton *m_clearButton; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // elapsed time display
 | 
					
						
							|  |  |  |     QTimer m_recordingTimer; | 
					
						
							|  |  |  |     QTime m_recordingElapsedTime; | 
					
						
							|  |  |  |     QLabel *m_timeLabel; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  |     // open search
 | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  |     QToolButton *m_searchButton; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     // hide and show categories
 | 
					
						
							|  |  |  |     QToolButton *m_displayFeaturesButton; | 
					
						
							|  |  |  |     QMenu *m_displayFeaturesMenu; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     // save and load actions
 | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  |     QAction *m_saveQmlTrace; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     QAction *m_loadQmlTrace; | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-30 18:55:48 +02:00
										 |  |  | QmlProfilerTool::QmlProfilerTool(QObject *parent) | 
					
						
							| 
									
										
										
										
											2015-02-18 14:35:20 +01:00
										 |  |  |     : QObject(parent), d(new QmlProfilerToolPrivate) | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-26 21:18:13 +02:00
										 |  |  |     setObjectName(QLatin1String("QmlProfilerTool")); | 
					
						
							| 
									
										
										
										
											2011-05-20 13:36:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     d->m_profilerState = 0; | 
					
						
							|  |  |  |     d->m_viewContainer = 0; | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     d->m_recordButton = 0; | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_recordFeaturesMenu = 0; | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     d->m_clearButton = 0; | 
					
						
							|  |  |  |     d->m_timeLabel = 0; | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  |     d->m_searchButton = 0; | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_displayFeaturesButton = 0; | 
					
						
							|  |  |  |     d->m_displayFeaturesMenu = 0; | 
					
						
							| 
									
										
										
										
											2011-06-30 13:44:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     d->m_profilerState = new QmlProfilerStateManager(this); | 
					
						
							|  |  |  |     connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged())); | 
					
						
							|  |  |  |     connect(d->m_profilerState, SIGNAL(clientRecordingChanged()), this, SLOT(clientRecordingChanged())); | 
					
						
							|  |  |  |     connect(d->m_profilerState, SIGNAL(serverRecordingChanged()), this, SLOT(serverRecordingChanged())); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     connect(d->m_profilerState, &QmlProfilerStateManager::recordedFeaturesChanged, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::setRecordedFeatures); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     d->m_profilerConnections = new QmlProfilerClientManager(this); | 
					
						
							|  |  |  |     d->m_profilerConnections->registerProfilerStateManager(d->m_profilerState); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:14:11 +02:00
										 |  |  |     connect(d->m_profilerConnections, SIGNAL(connectionClosed()), this, SLOT(clientsDisconnected())); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     d->m_profilerModelManager = new QmlProfilerModelManager(&d->m_projectFinder, this); | 
					
						
							|  |  |  |     connect(d->m_profilerModelManager, SIGNAL(stateChanged()), this, SLOT(profilerDataModelStateChanged())); | 
					
						
							|  |  |  |     connect(d->m_profilerModelManager, SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString))); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     connect(d->m_profilerModelManager, &QmlProfilerModelManager::availableFeaturesChanged, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::setAvailableFeatures); | 
					
						
							| 
									
										
										
										
											2015-02-10 20:29:54 +01:00
										 |  |  |     connect(d->m_profilerModelManager, &QmlProfilerModelManager::saveFinished, | 
					
						
							| 
									
										
										
										
											2015-02-17 14:25:24 +01:00
										 |  |  |             this, &QmlProfilerTool::onLoadSaveFinished); | 
					
						
							|  |  |  |     connect(d->m_profilerModelManager, &QmlProfilerModelManager::loadFinished, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::onLoadSaveFinished); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     d->m_profilerConnections->setModelManager(d->m_profilerModelManager); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  |     Command *command = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  |     ActionContainer *menu = ActionManager::actionContainer(M_DEBUG_ANALYZER); | 
					
						
							|  |  |  |     ActionContainer *options = ActionManager::createMenu(M_DEBUG_ANALYZER_QML_OPTIONS); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  |     options->menu()->setTitle(tr("QML Profiler Options")); | 
					
						
							|  |  |  |     menu->addMenu(options, G_ANALYZER_OPTIONS); | 
					
						
							|  |  |  |     options->menu()->setEnabled(true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     QAction *act = d->m_loadQmlTrace = new QAction(tr("Load QML Trace"), options); | 
					
						
							| 
									
										
										
										
											2015-02-19 11:35:47 +01:00
										 |  |  |     command = ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.LoadQMLTrace"); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  |     connect(act, SIGNAL(triggered()), this, SLOT(showLoadDialog())); | 
					
						
							|  |  |  |     options->addAction(command); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     act = d->m_saveQmlTrace = new QAction(tr("Save QML Trace"), options); | 
					
						
							|  |  |  |     d->m_saveQmlTrace->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2015-02-19 11:35:47 +01:00
										 |  |  |     command = ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.SaveQMLTrace"); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  |     connect(act, SIGNAL(triggered()), this, SLOT(showSaveDialog())); | 
					
						
							|  |  |  |     options->addAction(command); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     d->m_recordingTimer.setInterval(100); | 
					
						
							|  |  |  |     connect(&d->m_recordingTimer, SIGNAL(timeout()), this, SLOT(updateTimeDisplay())); | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QmlProfilerTool::~QmlProfilerTool() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete d; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-30 14:08:01 +02:00
										 |  |  | AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParameters &sp, | 
					
						
							| 
									
										
										
										
											2011-09-14 13:12:25 +02:00
										 |  |  |     RunConfiguration *runConfiguration) | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-08-28 12:50:46 +02:00
										 |  |  |     QmlProfilerRunConfigurationAspect *aspect = static_cast<QmlProfilerRunConfigurationAspect *>( | 
					
						
							|  |  |  |                 runConfiguration->extraAspect(Constants::SETTINGS)); | 
					
						
							|  |  |  |     QTC_ASSERT(aspect, return 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QmlProfilerSettings *settings = static_cast<QmlProfilerSettings *>(aspect->currentSettings()); | 
					
						
							|  |  |  |     QTC_ASSERT(settings, return 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     d->m_profilerConnections->setFlushInterval(settings->flushEnabled() ? | 
					
						
							|  |  |  |                                                    settings->flushInterval() : 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-30 14:08:01 +02:00
										 |  |  |     QmlProfilerRunControl *engine = new QmlProfilerRunControl(sp, runConfiguration); | 
					
						
							| 
									
										
										
										
											2011-06-10 17:09:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     engine->registerProfilerStateManager(d->m_profilerState); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool isTcpConnection = true; | 
					
						
							| 
									
										
										
										
											2011-06-09 14:34:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-05 12:14:41 +02:00
										 |  |  |     // FIXME: Check that there's something sensible in sp.connParams
 | 
					
						
							| 
									
										
										
											
												Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
											
										 
											2013-01-08 03:32:53 +02:00
										 |  |  |     if (isTcpConnection) | 
					
						
							| 
									
										
										
										
											2013-04-22 17:11:06 +02:00
										 |  |  |         d->m_profilerConnections->setTcpConnection(sp.analyzerHost, sp.analyzerPort); | 
					
						
							| 
									
										
										
										
											2011-04-14 15:44:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-28 16:32:34 +02:00
										 |  |  |     //
 | 
					
						
							|  |  |  |     // Initialize m_projectFinder
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString projectDirectory; | 
					
						
							| 
									
										
										
										
											2013-07-11 18:07:15 +02:00
										 |  |  |     if (runConfiguration) { | 
					
						
							|  |  |  |         Project *project = runConfiguration->target()->project(); | 
					
						
							| 
									
										
										
										
											2014-05-02 12:53:36 +02:00
										 |  |  |         projectDirectory = project->projectDirectory().toString(); | 
					
						
							| 
									
										
										
										
											2011-10-28 16:32:34 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-09-14 13:12:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 11:46:59 +02:00
										 |  |  |     populateFileFinder(projectDirectory, sp.sysroot); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:32:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     connect(engine, SIGNAL(processRunning(quint16)), d->m_profilerConnections, SLOT(connectClient(quint16))); | 
					
						
							|  |  |  |     connect(d->m_profilerConnections, SIGNAL(connectionFailed()), engine, SLOT(cancelProcess())); | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return engine; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 14:30:32 +02:00
										 |  |  | static QString sysroot(RunConfiguration *runConfig) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QTC_ASSERT(runConfig, return QString()); | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  |     Kit *k = runConfig->target()->kit(); | 
					
						
							|  |  |  |     if (k && SysRootKitInformation::hasSysRoot(k)) | 
					
						
							|  |  |  |         return SysRootKitInformation::sysRoot(runConfig->target()->kit()).toString(); | 
					
						
							| 
									
										
										
										
											2012-05-10 14:30:32 +02:00
										 |  |  |     return QString(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-06 16:52:14 +02:00
										 |  |  | QWidget *QmlProfilerTool::createWidgets() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     QTC_ASSERT(!d->m_viewContainer, return 0); | 
					
						
							| 
									
										
										
										
											2011-04-08 13:05:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-27 14:38:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     d->m_viewContainer = new QmlProfilerViewManager(this, | 
					
						
							|  |  |  |                                                     this, | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |                                                     d->m_profilerModelManager, | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |                                                     d->m_profilerState); | 
					
						
							|  |  |  |     connect(d->m_viewContainer, SIGNAL(gotoSourceLocation(QString,int,int)), | 
					
						
							|  |  |  |             this, SLOT(gotoSourceLocation(QString,int,int))); | 
					
						
							| 
									
										
										
										
											2011-07-06 14:13:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-06 16:52:14 +02:00
										 |  |  |     //
 | 
					
						
							|  |  |  |     // Toolbar
 | 
					
						
							|  |  |  |     //
 | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  |     QWidget *toolbarWidget = new QWidget; | 
					
						
							|  |  |  |     toolbarWidget->setObjectName(QLatin1String("QmlProfilerToolBarWidget")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QHBoxLayout *layout = new QHBoxLayout; | 
					
						
							|  |  |  |     layout->setMargin(0); | 
					
						
							|  |  |  |     layout->setSpacing(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-06 12:26:19 +02:00
										 |  |  |     d->m_recordButton = new QToolButton(toolbarWidget); | 
					
						
							|  |  |  |     d->m_recordButton->setCheckable(true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  |     connect(d->m_recordButton,SIGNAL(clicked(bool)), this, SLOT(recordingButtonChanged(bool))); | 
					
						
							| 
									
										
										
										
											2011-04-06 12:26:19 +02:00
										 |  |  |     d->m_recordButton->setChecked(true); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_recordFeaturesMenu = new QMenu(d->m_recordButton); | 
					
						
							|  |  |  |     d->m_recordButton->setMenu(d->m_recordFeaturesMenu); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     d->m_recordButton->setPopupMode(QToolButton::MenuButtonPopup); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     connect(d->m_recordFeaturesMenu, SIGNAL(triggered(QAction*)), | 
					
						
							|  |  |  |             this, SLOT(toggleRequestedFeature(QAction*))); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     setRecording(d->m_profilerState->clientRecording()); | 
					
						
							| 
									
										
										
										
											2011-04-06 12:26:19 +02:00
										 |  |  |     layout->addWidget(d->m_recordButton); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-24 18:19:08 +02:00
										 |  |  |     d->m_clearButton = new QToolButton(toolbarWidget); | 
					
						
							| 
									
										
										
										
											2015-10-19 12:55:13 +02:00
										 |  |  |     d->m_clearButton->setIcon(Utils::ThemeHelper::themedIcon(QLatin1String(ICON_CLEAN_PANE))); | 
					
						
							| 
									
										
										
										
											2011-07-05 16:40:26 +02:00
										 |  |  |     d->m_clearButton->setToolTip(tr("Discard data")); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |     connect(d->m_clearButton, &QAbstractButton::clicked, [this](){ | 
					
						
							|  |  |  |         if (checkForUnsavedNotes()) | 
					
						
							|  |  |  |             clearData(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-24 18:19:08 +02:00
										 |  |  |     layout->addWidget(d->m_clearButton); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  |     d->m_searchButton = new QToolButton; | 
					
						
							| 
									
										
										
										
											2015-10-19 12:55:13 +02:00
										 |  |  |     d->m_searchButton->setIcon(Utils::ThemeHelper::themedIcon(QLatin1String(ICON_ZOOM))); | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  |     d->m_searchButton->setToolTip(tr("Search timeline event notes.")); | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  |     layout->addWidget(d->m_searchButton); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  |     connect(d->m_searchButton, &QToolButton::clicked, this, &QmlProfilerTool::showTimeLineSearch); | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_displayFeaturesButton = new QToolButton; | 
					
						
							| 
									
										
										
										
											2015-10-19 12:55:13 +02:00
										 |  |  |     d->m_displayFeaturesButton->setIcon(Utils::ThemeHelper::themedIcon(QLatin1String(ICON_FILTER))); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_displayFeaturesButton->setToolTip(tr("Hide or show event categories.")); | 
					
						
							|  |  |  |     d->m_displayFeaturesButton->setPopupMode(QToolButton::InstantPopup); | 
					
						
							| 
									
										
										
										
											2015-09-28 19:14:46 +02:00
										 |  |  |     d->m_displayFeaturesButton->setProperty("noArrow", true); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_displayFeaturesMenu = new QMenu(d->m_displayFeaturesButton); | 
					
						
							|  |  |  |     d->m_displayFeaturesButton->setMenu(d->m_displayFeaturesMenu); | 
					
						
							|  |  |  |     connect(d->m_displayFeaturesMenu, &QMenu::triggered, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::toggleVisibleFeature); | 
					
						
							|  |  |  |     layout->addWidget(d->m_displayFeaturesButton); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:05:03 +02:00
										 |  |  |     d->m_timeLabel = new QLabel(); | 
					
						
							|  |  |  |     QPalette palette; | 
					
						
							|  |  |  |     palette.setColor(QPalette::WindowText, Qt::white); | 
					
						
							|  |  |  |     d->m_timeLabel->setPalette(palette); | 
					
						
							|  |  |  |     d->m_timeLabel->setIndent(10); | 
					
						
							|  |  |  |     updateTimeDisplay(); | 
					
						
							|  |  |  |     layout->addWidget(d->m_timeLabel); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  |     layout->addStretch(); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  |     toolbarWidget->setLayout(layout); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     setAvailableFeatures(d->m_profilerModelManager->availableFeatures()); | 
					
						
							|  |  |  |     setRecordedFeatures(0); | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 11:46:59 +02:00
										 |  |  |     // When the widgets are requested we assume that the session data
 | 
					
						
							|  |  |  |     // is available, then we can populate the file finder
 | 
					
						
							|  |  |  |     populateFileFinder(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  |     return toolbarWidget; | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 11:46:59 +02:00
										 |  |  | void QmlProfilerTool::populateFileFinder(QString projectDirectory, QString activeSysroot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // Initialize filefinder with some sensible default
 | 
					
						
							|  |  |  |     QStringList sourceFiles; | 
					
						
							| 
									
										
										
										
											2013-09-05 11:46:07 +02:00
										 |  |  |     QList<Project *> projects = SessionManager::projects(); | 
					
						
							|  |  |  |     if (Project *startupProject = SessionManager::startupProject()) { | 
					
						
							| 
									
										
										
										
											2012-05-10 11:46:59 +02:00
										 |  |  |         // startup project first
 | 
					
						
							| 
									
										
										
										
											2013-09-05 11:46:07 +02:00
										 |  |  |         projects.removeOne(startupProject); | 
					
						
							| 
									
										
										
										
											2012-05-10 11:46:59 +02:00
										 |  |  |         projects.insert(0, startupProject); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     foreach (Project *project, projects) | 
					
						
							|  |  |  |         sourceFiles << project->files(Project::ExcludeGeneratedFiles); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!projects.isEmpty()) { | 
					
						
							| 
									
										
										
											
												Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
											
										 
											2013-01-08 03:32:53 +02:00
										 |  |  |         if (projectDirectory.isEmpty()) | 
					
						
							| 
									
										
										
										
											2014-05-02 12:53:36 +02:00
										 |  |  |             projectDirectory = projects.first()->projectDirectory().toString(); | 
					
						
							| 
									
										
										
										
											2012-05-10 11:46:59 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (activeSysroot.isEmpty()) { | 
					
						
							|  |  |  |             if (Target *target = projects.first()->activeTarget()) | 
					
						
							|  |  |  |                 if (RunConfiguration *rc = target->activeRunConfiguration()) | 
					
						
							|  |  |  |                     activeSysroot = sysroot(rc); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     d->m_projectFinder.setProjectDirectory(projectDirectory); | 
					
						
							|  |  |  |     d->m_projectFinder.setProjectFiles(sourceFiles); | 
					
						
							|  |  |  |     d->m_projectFinder.setSysroot(activeSysroot); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  | void QmlProfilerTool::recordingButtonChanged(bool recording) | 
					
						
							| 
									
										
										
										
											2011-04-06 12:26:19 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-17 17:32:52 +01:00
										 |  |  |     // clientRecording is our intention for new sessions. That may differ from the state of the
 | 
					
						
							|  |  |  |     // current session, as indicated by the button. To synchronize it, toggle once.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |     if (recording && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) { | 
					
						
							|  |  |  |         if (checkForUnsavedNotes()) { | 
					
						
							|  |  |  |             clearData(); // clear right away, before the application starts
 | 
					
						
							| 
									
										
										
										
											2014-11-17 17:32:52 +01:00
										 |  |  |             if (d->m_profilerState->clientRecording()) | 
					
						
							|  |  |  |                 d->m_profilerState->setClientRecording(false); | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |             d->m_profilerState->setClientRecording(true); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             d->m_recordButton->setChecked(false); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2014-11-17 17:32:52 +01:00
										 |  |  |         if (d->m_profilerState->clientRecording() == recording) | 
					
						
							|  |  |  |             d->m_profilerState->setClientRecording(!recording); | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |         d->m_profilerState->setClientRecording(recording); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::setRecording(bool recording) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     // update display
 | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  |     d->m_recordButton->setToolTip( recording ? tr("Disable profiling") : tr("Enable profiling")); | 
					
						
							|  |  |  |     d->m_recordButton->setIcon(QIcon(recording ? QLatin1String(":/qmlprofiler/recordOn.png") : | 
					
						
							|  |  |  |                                                  QLatin1String(":/qmlprofiler/recordOff.png"))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     d->m_recordButton->setChecked(recording); | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     // manage timer
 | 
					
						
							|  |  |  |     if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) { | 
					
						
							|  |  |  |         if (recording) { | 
					
						
							|  |  |  |             d->m_recordingTimer.start(); | 
					
						
							|  |  |  |             d->m_recordingElapsedTime.start(); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             d->m_recordingTimer.stop(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-08-25 16:30:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-12 16:36:40 +01:00
										 |  |  | void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber, int columnNumber) | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-04-01 13:57:49 +02:00
										 |  |  |     if (lineNumber < 0 || fileUrl.isEmpty()) | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-21 12:15:31 +01:00
										 |  |  |     const QString projectFileName = d->m_projectFinder.findFile(fileUrl); | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-09 11:01:03 +01:00
										 |  |  |     QFileInfo fileInfo(projectFileName); | 
					
						
							|  |  |  |     if (!fileInfo.exists() || !fileInfo.isReadable()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-17 19:12:44 +01:00
										 |  |  |     // The text editors count columns starting with 0, but the ASTs store the
 | 
					
						
							|  |  |  |     // location starting with 1, therefore the -1.
 | 
					
						
							|  |  |  |     EditorManager::openEditorAt(projectFileName, lineNumber, columnNumber - 1, Id(), | 
					
						
							|  |  |  |                                 EditorManager::DoNotSwitchToDesignMode); | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::updateTimeDisplay() | 
					
						
							| 
									
										
										
										
											2011-11-28 16:30:30 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     double seconds = 0; | 
					
						
							| 
									
										
										
										
											2015-10-20 13:04:44 +02:00
										 |  |  |     switch (d->m_profilerState->currentState()) { | 
					
						
							|  |  |  |     case QmlProfilerStateManager::AppStopRequested: | 
					
						
							|  |  |  |     case QmlProfilerStateManager::AppDying: | 
					
						
							|  |  |  |         return; // Transitional state: don't update the display.
 | 
					
						
							|  |  |  |     case QmlProfilerStateManager::AppRunning: | 
					
						
							|  |  |  |         if (d->m_profilerState->serverRecording()) { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |             seconds = d->m_recordingElapsedTime.elapsed() / 1000.0; | 
					
						
							| 
									
										
										
										
											2015-10-20 13:04:44 +02:00
										 |  |  |             break; | 
					
						
							|  |  |  |         } // else fall through
 | 
					
						
							|  |  |  |     case QmlProfilerStateManager::Idle: | 
					
						
							|  |  |  |         if (d->m_profilerModelManager->state() != QmlProfilerModelManager::Empty && | 
					
						
							|  |  |  |                d->m_profilerModelManager->state() != QmlProfilerModelManager::ClearingData) | 
					
						
							|  |  |  |             seconds = d->m_profilerModelManager->traceTime()->duration() / 1.0e9; | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-11-28 16:30:30 +01:00
										 |  |  |     QString timeString = QString::number(seconds,'f',1); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     QString profilerTimeStr = QmlProfilerTool::tr("%1 s").arg(timeString, 6); | 
					
						
							|  |  |  |     d->m_timeLabel->setText(tr("Elapsed: %1").arg(profilerTimeStr)); | 
					
						
							| 
									
										
										
										
											2011-11-28 16:30:30 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  | void QmlProfilerTool::showTimeLineSearch() | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  |     d->m_viewContainer->raiseTimeline(); | 
					
						
							|  |  |  |     Core::FindPlugin::instance()->openFindToolBar(Core::FindPlugin::FindForwardDirection); | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::clearData() | 
					
						
							| 
									
										
										
										
											2011-11-28 16:30:30 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     d->m_profilerModelManager->clear(); | 
					
						
							| 
									
										
										
										
											2012-03-26 16:20:09 +02:00
										 |  |  |     d->m_profilerConnections->discardPendingData(); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     setRecordedFeatures(0); | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-04-01 13:48:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-06 16:04:18 +02:00
										 |  |  | void QmlProfilerTool::clearDisplay() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     d->m_profilerConnections->clearBufferedData(); | 
					
						
							|  |  |  |     d->m_viewContainer->clear(); | 
					
						
							|  |  |  |     updateTimeDisplay(); | 
					
						
							| 
									
										
										
										
											2011-04-06 16:04:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  | void QmlProfilerTool::setButtonsEnabled(bool enable) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d->m_clearButton->setEnabled(enable); | 
					
						
							|  |  |  |     d->m_displayFeaturesButton->setEnabled(enable); | 
					
						
							|  |  |  |     d->m_searchButton->setEnabled(enable); | 
					
						
							|  |  |  |     d->m_recordFeaturesMenu->setEnabled(enable); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-18 16:26:58 +02:00
										 |  |  | bool QmlProfilerTool::prepareTool() | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-02-18 18:51:29 +01:00
										 |  |  |     if (d->m_recordButton->isChecked()) { | 
					
						
							| 
									
										
										
										
											2015-06-18 16:26:58 +02:00
										 |  |  |         if (checkForUnsavedNotes()) { | 
					
						
							|  |  |  |             clearData(); // clear right away to suppress second warning on server recording change
 | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-02-18 18:51:29 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-06-18 16:26:58 +02:00
										 |  |  |     return true; | 
					
						
							| 
									
										
										
										
											2015-02-18 18:51:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::startRemoteTool() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     AnalyzerManager::showMode(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |     Id kitId; | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  |     quint16 port; | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |     Kit *kit = 0; | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |         QSettings *settings = ICore::settings(); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |         kitId = Id::fromSetting(settings->value(QLatin1String("AnalyzerQmlAttachDialog/kitId"))); | 
					
						
							|  |  |  |         port = settings->value(QLatin1String("AnalyzerQmlAttachDialog/port"), 3768).toUInt(); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         QmlProfilerAttachDialog dialog; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |         dialog.setKitId(kitId); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  |         dialog.setPort(port); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (dialog.exec() != QDialog::Accepted) | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |         kit = dialog.kit(); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  |         port = dialog.port(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |         settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/kitId"), kit->id().toSetting()); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  |         settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/port"), port); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-14 13:12:25 +02:00
										 |  |  |     AnalyzerStartParameters sp; | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IDevice::ConstPtr device = DeviceKitInformation::device(kit); | 
					
						
							|  |  |  |     if (device) { | 
					
						
							|  |  |  |         sp.connParams = device->sshParameters(); | 
					
						
							| 
									
										
										
										
											2013-10-11 12:58:24 +02:00
										 |  |  |         sp.analyzerHost = device->qmlProfilerHost(); | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     sp.sysroot = SysRootKitInformation::sysRoot(kit).toString(); | 
					
						
							| 
									
										
										
										
											2013-04-22 17:11:06 +02:00
										 |  |  |     sp.analyzerPort = port; | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-18 18:51:29 +01:00
										 |  |  |     AnalyzerRunControl *rc = createRunControl(sp, 0); | 
					
						
							| 
									
										
										
										
											2015-06-29 10:36:29 +03:00
										 |  |  |     ProjectExplorerPlugin::startRunControl(rc, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-04-04 15:56:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-06 15:44:34 +02:00
										 |  |  | void QmlProfilerTool::logState(const QString &msg) | 
					
						
							| 
									
										
										
										
											2011-07-27 11:49:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  |     MessageManager::write(msg, MessageManager::Flash); | 
					
						
							| 
									
										
										
										
											2011-07-27 11:49:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::logError(const QString &msg) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-09-05 01:52:17 +02:00
										 |  |  |     MessageManager::write(msg); | 
					
						
							| 
									
										
										
										
											2011-07-27 11:49:39 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::showErrorDialog(const QString &error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  |     QMessageBox *errorDialog = new QMessageBox(ICore::mainWindow()); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     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(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-03 14:34:34 +01:00
										 |  |  | void QmlProfilerTool::showLoadOption() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d->m_loadQmlTrace->setEnabled(!d->m_profilerState->serverRecording()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | void QmlProfilerTool::showSaveOption() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     d->m_saveQmlTrace->setEnabled(!d->m_profilerModelManager->isEmpty()); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  | void saveLastTraceFile(const QString &filename) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings(); | 
					
						
							|  |  |  |     if (filename != settings->lastTraceFile()) { | 
					
						
							|  |  |  |         settings->setLastTraceFile(filename); | 
					
						
							|  |  |  |         settings->writeGlobalSettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  | void QmlProfilerTool::showSaveDialog() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  |     QString filename = QFileDialog::getSaveFileName( | 
					
						
							|  |  |  |                 ICore::mainWindow(), tr("Save QML Trace"), | 
					
						
							|  |  |  |                 QmlProfilerPlugin::globalSettings()->lastTraceFile(), | 
					
						
							|  |  |  |                 tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension))); | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  |     if (!filename.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2011-08-22 16:01:50 +02:00
										 |  |  |         if (!filename.endsWith(QLatin1String(TraceFileExtension))) | 
					
						
							|  |  |  |             filename += QLatin1String(TraceFileExtension); | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  |         saveLastTraceFile(filename); | 
					
						
							| 
									
										
										
										
											2015-02-10 20:29:54 +01:00
										 |  |  |         AnalyzerManager::mainWindow()->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |         d->m_profilerModelManager->save(filename); | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::showLoadDialog() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |     if (!checkForUnsavedNotes()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-07 18:28:03 +02:00
										 |  |  |     if (ModeManager::currentMode()->id() != MODE_ANALYZE) | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  |         AnalyzerManager::showMode(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 18:08:44 +02:00
										 |  |  |     AnalyzerManager::selectAction(QmlProfilerRemoteActionId); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  |     QString filename = QFileDialog::getOpenFileName( | 
					
						
							|  |  |  |                 ICore::mainWindow(), tr("Load QML Trace"), | 
					
						
							|  |  |  |                 QmlProfilerPlugin::globalSettings()->lastTraceFile(), | 
					
						
							|  |  |  |                 tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension))); | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (!filename.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  |         saveLastTraceFile(filename); | 
					
						
							| 
									
										
										
										
											2015-02-17 14:25:24 +01:00
										 |  |  |         AnalyzerManager::mainWindow()->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         connect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged, | 
					
						
							|  |  |  |                 this, &QmlProfilerTool::setRecordedFeatures); | 
					
						
							| 
									
										
										
										
											2015-02-17 14:25:24 +01:00
										 |  |  |         d->m_profilerModelManager->load(filename); | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-08-18 16:10:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 14:25:24 +01:00
										 |  |  | void QmlProfilerTool::onLoadSaveFinished() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     disconnect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged, | 
					
						
							|  |  |  |                this, &QmlProfilerTool::setRecordedFeatures); | 
					
						
							| 
									
										
										
										
											2015-02-17 14:25:24 +01:00
										 |  |  |     AnalyzerManager::mainWindow()->setEnabled(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  | /*!
 | 
					
						
							|  |  |  |     Checks if we have unsaved notes. If so, shows a warning dialog. Returns true if we can continue | 
					
						
							|  |  |  |     with a potentially destructive operation and discard the warnings, or false if not. We don't | 
					
						
							|  |  |  |     want to show a save/discard dialog here because that will often result in a confusing series of | 
					
						
							|  |  |  |     different dialogs: first "save" and then immediately "load" or "connect". | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | bool QmlProfilerTool::checkForUnsavedNotes() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!d->m_profilerModelManager->notesModel()->isModified()) | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     return QMessageBox::warning(QApplication::activeWindow(), tr("QML Profiler"), | 
					
						
							|  |  |  |                                 tr("You are about to discard the profiling data, including unsaved " | 
					
						
							|  |  |  |                                    "notes. Do you want to continue?"), | 
					
						
							|  |  |  |                                 QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::restoreFeatureVisibility() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // Restore the shown/hidden state of features to what the user selected. When clearing data the
 | 
					
						
							|  |  |  |     // the model manager sets its features to 0, and models get automatically shown, for the mockup.
 | 
					
						
							|  |  |  |     quint64 features = 0; | 
					
						
							|  |  |  |     foreach (const QAction *action, d->m_displayFeaturesMenu->actions()) { | 
					
						
							|  |  |  |         if (action->isChecked()) | 
					
						
							|  |  |  |             features |= (1ULL << action->data().toUInt()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     d->m_profilerModelManager->setVisibleFeatures(features); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:14:11 +02:00
										 |  |  | void QmlProfilerTool::clientsDisconnected() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // If the application stopped by itself, check if we have all the data
 | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |     if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying || | 
					
						
							|  |  |  |             d->m_profilerState->currentState() == QmlProfilerStateManager::Idle) { | 
					
						
							| 
									
										
										
										
											2015-09-11 16:10:58 +02:00
										 |  |  |         if (d->m_profilerModelManager->state() == QmlProfilerModelManager::AcquiringData) { | 
					
						
							|  |  |  |             showNonmodalWarning(tr("Application finished before loading profiled data.\n" | 
					
						
							|  |  |  |                                    "Please use the stop button instead.")); | 
					
						
							|  |  |  |             d->m_profilerModelManager->clear(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-05-08 15:14:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // ... and return to the "base" state
 | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |         if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) | 
					
						
							|  |  |  |             d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:14:11 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     // If the connection is closed while the app is still running, no special action is needed
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void addFeatureToMenu(QMenu *menu, ProfileFeature feature, quint64 enabledFeatures) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QAction *action = | 
					
						
							|  |  |  |             menu->addAction(QmlProfilerTool::tr(QmlProfilerModelManager::featureName(feature))); | 
					
						
							|  |  |  |     action->setCheckable(true); | 
					
						
							|  |  |  |     action->setData(static_cast<uint>(feature)); | 
					
						
							|  |  |  |     action->setChecked(enabledFeatures & (1ULL << (feature))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-03 23:48:57 +02:00
										 |  |  | template<ProfileFeature feature> | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::updateFeatures(quint64 features) | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-24 07:59:13 +03:00
										 |  |  |     if (features & (1ULL << (feature))) { | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         addFeatureToMenu(d->m_recordFeaturesMenu, feature, | 
					
						
							|  |  |  |                          d->m_profilerState->requestedFeatures()); | 
					
						
							|  |  |  |         addFeatureToMenu(d->m_displayFeaturesMenu, feature, | 
					
						
							|  |  |  |                          d->m_profilerModelManager->visibleFeatures()); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     updateFeatures<static_cast<ProfileFeature>(feature + 1)>(features); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::updateFeatures<MaximumProfileFeature>(quint64 features) | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     Q_UNUSED(features); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::setAvailableFeatures(quint64 features) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     if (features != d->m_profilerState->requestedFeatures()) | 
					
						
							|  |  |  |         d->m_profilerState->setRequestedFeatures(features); // by default, enable them all.
 | 
					
						
							|  |  |  |     if (d->m_recordFeaturesMenu && d->m_displayFeaturesMenu) { | 
					
						
							|  |  |  |         d->m_recordFeaturesMenu->clear(); | 
					
						
							|  |  |  |         d->m_displayFeaturesMenu->clear(); | 
					
						
							|  |  |  |         updateFeatures<static_cast<ProfileFeature>(0)>(features); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::setRecordedFeatures(quint64 features) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     foreach (QAction *action, d->m_displayFeaturesMenu->actions()) | 
					
						
							|  |  |  |         action->setEnabled(features & (1ULL << action->data().toUInt())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::profilerDataModelStateChanged() | 
					
						
							| 
									
										
										
										
											2011-08-18 16:10:33 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     switch (d->m_profilerModelManager->state()) { | 
					
						
							| 
									
										
										
										
											2015-09-10 13:51:54 +02:00
										 |  |  |     case QmlProfilerModelManager::Empty : | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |         d->m_recordButton->setEnabled(true); | 
					
						
							|  |  |  |         setButtonsEnabled(true); | 
					
						
							| 
									
										
										
										
											2013-12-09 12:11:48 +01:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-09-10 13:51:54 +02:00
										 |  |  |     case QmlProfilerModelManager::ClearingData : | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |         d->m_recordButton->setEnabled(false); | 
					
						
							|  |  |  |         setButtonsEnabled(false); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |         clearDisplay(); | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-09-10 13:51:54 +02:00
										 |  |  |     case QmlProfilerModelManager::AcquiringData : | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |         d->m_recordButton->setEnabled(true); // Press recording button to stop recording
 | 
					
						
							|  |  |  |         setButtonsEnabled(false);            // Other buttons disabled
 | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-09-10 13:51:54 +02:00
										 |  |  |     case QmlProfilerModelManager::ProcessingData : | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |         d->m_recordButton->setEnabled(false); | 
					
						
							|  |  |  |         setButtonsEnabled(false); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-09-10 13:51:54 +02:00
										 |  |  |     case QmlProfilerModelManager::Done : | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |         if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStopRequested) | 
					
						
							| 
									
										
										
										
											2015-09-11 16:10:58 +02:00
										 |  |  |             d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |         showSaveOption(); | 
					
						
							|  |  |  |         updateTimeDisplay(); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         restoreFeatureVisibility(); | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |         d->m_recordButton->setEnabled(true); | 
					
						
							|  |  |  |         setButtonsEnabled(true); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QList <QAction *> QmlProfilerTool::profilerContextMenuActions() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QList <QAction *> commonActions; | 
					
						
							|  |  |  |     commonActions << d->m_loadQmlTrace << d->m_saveQmlTrace; | 
					
						
							|  |  |  |     return commonActions; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::showNonmodalWarning(const QString &warningMsg) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  |     QMessageBox *noExecWarning = new QMessageBox(ICore::mainWindow()); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     noExecWarning->setIcon(QMessageBox::Warning); | 
					
						
							|  |  |  |     noExecWarning->setWindowTitle(tr("QML Profiler")); | 
					
						
							|  |  |  |     noExecWarning->setText(warningMsg); | 
					
						
							|  |  |  |     noExecWarning->setStandardButtons(QMessageBox::Ok); | 
					
						
							|  |  |  |     noExecWarning->setDefaultButton(QMessageBox::Ok); | 
					
						
							|  |  |  |     noExecWarning->setModal(false); | 
					
						
							|  |  |  |     noExecWarning->show(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QMessageBox *QmlProfilerTool::requestMessageBox() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  |     return new QMessageBox(ICore::mainWindow()); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::handleHelpRequest(const QString &link) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-08-29 19:00:34 +02:00
										 |  |  |     HelpManager::handleHelpRequest(link); | 
					
						
							| 
									
										
										
										
											2011-08-18 16:10:33 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-09-14 13:26:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::profilerStateChanged() | 
					
						
							| 
									
										
										
										
											2011-09-14 13:26:19 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     switch (d->m_profilerState->currentState()) { | 
					
						
							| 
									
										
										
										
											2012-05-11 17:19:15 +02:00
										 |  |  |     case QmlProfilerStateManager::AppDying : { | 
					
						
							|  |  |  |         // If already disconnected when dying, check again that all data was read
 | 
					
						
							|  |  |  |         if (!d->m_profilerConnections->isConnected()) | 
					
						
							|  |  |  |             QTimer::singleShot(0, this, SLOT(clientsDisconnected())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     case QmlProfilerStateManager::Idle : | 
					
						
							|  |  |  |         // when the app finishes, set recording display to client status
 | 
					
						
							|  |  |  |         setRecording(d->m_profilerState->clientRecording()); | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |     case QmlProfilerStateManager::AppStopRequested: | 
					
						
							|  |  |  |         // Don't allow toggling the recording while data is loaded when application quits
 | 
					
						
							|  |  |  |         if (d->m_profilerState->serverRecording()) | 
					
						
							|  |  |  |             d->m_recordButton->setEnabled(false); | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     default: | 
					
						
							|  |  |  |         // no special action needed for other states
 | 
					
						
							| 
									
										
										
										
											2011-09-14 13:26:19 +02:00
										 |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::clientRecordingChanged() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // if application is running, display server record changes
 | 
					
						
							|  |  |  |     // if application is stopped, display client record changes
 | 
					
						
							| 
									
										
										
											
												Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
											
										 
											2013-01-08 03:32:53 +02:00
										 |  |  |     if (d->m_profilerState->currentState() != QmlProfilerStateManager::AppRunning) | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |         setRecording(d->m_profilerState->clientRecording()); | 
					
						
							| 
									
										
										
										
											2011-09-14 13:26:19 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::serverRecordingChanged() | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-03 14:34:34 +01:00
										 |  |  |     showLoadOption(); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) { | 
					
						
							|  |  |  |         // clear the old data each time we start a new profiling session
 | 
					
						
							|  |  |  |         if (d->m_profilerState->serverRecording()) { | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |             // We cannot stop it here, so we cannot give the usual yes/no dialog. Show a dialog
 | 
					
						
							|  |  |  |             // offering to immediately save the data instead.
 | 
					
						
							|  |  |  |             if (d->m_profilerModelManager->notesModel()->isModified() && | 
					
						
							|  |  |  |                     QMessageBox::warning(QApplication::activeWindow(), tr("QML Profiler"), | 
					
						
							|  |  |  |                                          tr("Starting a new profiling session will discard the " | 
					
						
							|  |  |  |                                             "previous data, including unsaved notes.\nDo you want " | 
					
						
							|  |  |  |                                             "to save the data first?"), | 
					
						
							|  |  |  |                                          QMessageBox::Save, QMessageBox::Discard) == | 
					
						
							|  |  |  |                     QMessageBox::Save) | 
					
						
							|  |  |  |                 showSaveDialog(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             setRecording(true); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |             clearData(); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |             d->m_profilerModelManager->prepareForWriting(); | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |             setRecording(false); | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // changes back once loading is finished, see profilerDataModelStateChanged()
 | 
					
						
							|  |  |  |             d->m_recordButton->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::toggleRequestedFeature(QAction *action) | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     uint feature = action->data().toUInt(); | 
					
						
							|  |  |  |     if (action->isChecked()) | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         d->m_profilerState->setRequestedFeatures( | 
					
						
							|  |  |  |                     d->m_profilerState->requestedFeatures() | (1ULL << feature)); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         d->m_profilerState->setRequestedFeatures( | 
					
						
							|  |  |  |                     d->m_profilerState->requestedFeatures() & (~(1ULL << feature))); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::toggleVisibleFeature(QAction *action) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     uint feature = action->data().toUInt(); | 
					
						
							|  |  |  |     if (action->isChecked()) | 
					
						
							|  |  |  |         d->m_profilerModelManager->setVisibleFeatures( | 
					
						
							|  |  |  |                     d->m_profilerModelManager->visibleFeatures() | (1ULL << feature)); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         d->m_profilerModelManager->setVisibleFeatures( | 
					
						
							|  |  |  |                     d->m_profilerModelManager->visibleFeatures() & (~(1ULL << feature))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | } |