analyzerruncontrol.cpp 2.82 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
Mike McQuaid's avatar
Mike McQuaid committed
2
**
3
** Copyright (C) 2016 The Qt Company Ltd.
Mike McQuaid's avatar
Mike McQuaid committed
4
** Author: Andreas Hartmetz, KDAB (andreas.hartmetz@kdab.com)
5
** Contact: https://www.qt.io/licensing/
Mike McQuaid's avatar
Mike McQuaid committed
6
**
hjk's avatar
hjk committed
7
** This file is part of Qt Creator.
Mike McQuaid's avatar
Mike McQuaid committed
8
**
hjk's avatar
hjk committed
9 10 11 12
** 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
13 14 15
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
Mike McQuaid's avatar
Mike McQuaid committed
16
**
17 18 19 20 21 22 23
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
Mike McQuaid's avatar
Mike McQuaid committed
24
**
hjk's avatar
hjk committed
25
****************************************************************************/
Mike McQuaid's avatar
Mike McQuaid committed
26

27
#include "analyzericons.h"
Mike McQuaid's avatar
Mike McQuaid committed
28 29 30 31
#include "analyzerruncontrol.h"
#include "ianalyzertool.h"
#include "analyzermanager.h"

32 33 34 35
#include <projectexplorer/project.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>

36
#include <QDebug>
Aurindam Jana's avatar
Aurindam Jana committed
37
#include <QAction>
Mike McQuaid's avatar
Mike McQuaid committed
38

hjk's avatar
hjk committed
39
using namespace ProjectExplorer;
Mike McQuaid's avatar
Mike McQuaid committed
40

hjk's avatar
hjk committed
41 42
//////////////////////////////////////////////////////////////////////////
//
43
// AnalyzerRunControl
hjk's avatar
hjk committed
44 45 46 47
//
//////////////////////////////////////////////////////////////////////////

namespace Analyzer {
Mike McQuaid's avatar
Mike McQuaid committed
48

49
AnalyzerRunControl::AnalyzerRunControl(RunConfiguration *runConfiguration, Core::Id runMode)
50
    : RunControl(runConfiguration, runMode)
hjk's avatar
hjk committed
51
{
52
    setIcon(Icons::ANALYZER_CONTROL_START);
53

Montel Laurent's avatar
Montel Laurent committed
54 55
    connect(this, &AnalyzerRunControl::finished,
            this, &AnalyzerRunControl::runControlFinished);
56 57
    connect(AnalyzerManager::stopAction(), &QAction::triggered,
            this, &AnalyzerRunControl::stopIt);
Mike McQuaid's avatar
Mike McQuaid committed
58 59
}

60
void AnalyzerRunControl::stopIt()
Mike McQuaid's avatar
Mike McQuaid committed
61
{
62 63 64
    if (stop() == RunControl::StoppedSynchronously)
        AnalyzerManager::handleToolFinished();
}
65

66 67 68 69
void AnalyzerRunControl::runControlFinished()
{
    m_isRunning = false;
    AnalyzerManager::handleToolFinished();
Mike McQuaid's avatar
Mike McQuaid committed
70 71 72 73
}

void AnalyzerRunControl::start()
{
74 75
    AnalyzerManager::handleToolStarted();

76 77
    if (startEngine()) {
        m_isRunning = true;
78 79
        emit started();
    }
Mike McQuaid's avatar
Mike McQuaid committed
80 81
}

hjk's avatar
hjk committed
82
RunControl::StopResult AnalyzerRunControl::stop()
Mike McQuaid's avatar
Mike McQuaid committed
83
{
84
    if (!m_isRunning)
85 86
        return StoppedSynchronously;

87 88
    stopEngine();
    m_isRunning = false;
Mike McQuaid's avatar
Mike McQuaid committed
89 90 91 92 93
    return AsynchronousStop;
}

bool AnalyzerRunControl::isRunning() const
{
94
    return m_isRunning;
Mike McQuaid's avatar
Mike McQuaid committed
95 96
}

hjk's avatar
hjk committed
97
} // namespace Analyzer